hi, I m stuck at a point for more than 3days. My doubt is pretty simple..
I have a web page content in $content. ( got this by using LWP)..
Now I want to display the content matching a pattern.
I tried
if($content =~ m{<div class="abc">(.*?)</div>}s){
print $1;}
that will display for only 1st pattern match..
Now I want to display content between each <div class="abc"> and </div> occuring in the $content and store in array.
Pls help me out how to do it...
how should i apply the while loop..
thanx..
you will also need the multiline modifier.. see perldoc perlre
what is multiline modifier...
I only want to know how could i apply while loop...
around the if condition so that it searches entire $content..
thankx
pludi
October 19, 2009, 3:48am
4
Hint 1: The modifier 'g' means 'global'
Hint 2:
$ echo '/a/ /b/ /c/ /d/' | perl -le '$c=<>; @a=($c=~m{/(.*?)/}g); print "@a";'
a b c d
Hint 3: perldoc perlretut , perldoc perlre
I tried
code:
@arr=($content =~ m{<div class="abs\c">(.*?)</div>}g);
print @arr;
but when i try putting s instead of g it print the content inside first occuring <div> tags pair in $content..
i still could not figure out the problem...
---------- Post updated at 03:02 AM ---------- Previous update was at 03:00 AM ----------
@arr=($content =~ m{<div class="abs\c">(.*?)</div>}g);
print @arr;
its not working
---------- Post updated at 03:27 AM ---------- Previous update was at 03:02 AM ----------
I got the it..!!!! jsst put s and g together... as...
@arr=($content =~ m{<div class="abs\c">(.*?)</div>}sg);
print @arr;