
borov
New User
Feb 27, 2007, 8:56 AM
Post #1 of 2
(976 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
#!/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?
|