CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Match multiple line string

 



borov
New User

Feb 27, 2007, 8:56 AM

Post #1 of 2 (2440 views)
Match multiple line string Can't Post

I want to match several strings between two html tags on the page, page is already on the hard disk, so there is no need to fetch it.
The string I want to match is something like
<pre class="s">
bla bla
bla bla bla bla
</pre>
but without all this html stuff

here is my script

Code
#!/usr/bin/perl 
use warnings;
use strict;

my $file = "A-Campfire-Song.html";

sub read_file {
my ($filename) = shift;
my @lines;

open (FILE, "$filename") or die "Can`t open $filename : $!";

while (<FILE>) {
push @lines, $_;
}

close FILE;
return @lines;
}

foreach my $match (&read_file($file)) {
print "Matched $match\n" if $match =~ m/<pre class=\"s\">(.*)/ig;
}


I read line after line so that is why regexp can`t match all that text... How can I convert all that several lines file array into scalar or to match somehow that text?


KevinR
Veteran


Feb 27, 2007, 10:36 AM

Post #2 of 2 (2435 views)
Re: [borov] Match multiple line string [In reply to] Can't Post

see if one of these FAQs is helpful:

http://www.perlguru.com/gforum.cgi?post=9166;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;;page=unread#unread

http://www.perlguru.com/gforum.cgi?post=9165;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;;page=unread#unread
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives