Home: Perl Programming Help: Beginner:
Print text between <source> and </source>



Gustaf
New User

Feb 14, 2013, 2:17 AM


Views: 547
Print text between <source> and </source>

Hello,

I'm new to perl and I would like to extract text between to strings. I would like to print all texts between <source> and </source> in a text file. The <source> and </source> could be on different rows.

Ex1
====
<source>Test</source>

=> print Text

Ex2
====
<source>Test1
av test1</source>
<source>Test2</source>

=> Print Test1
av test1
Test2


Thanks
Gustaf


BillKSmith
Veteran

Feb 14, 2013, 11:15 AM


Views: 540
Re: [Gustaf] Print text between <source> and </source>

This can be surprisingly difficult. I am sure it is worth the effort to search CPAN for a module that parses HTML. Perhaps someone else can recommend a specific one.
Good Luck,
Bill