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

New User

Feb 27, 2007, 8:56 AM

Views: 7401
Match multiple line string

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
but without all this html stuff

here is my script

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?


Feb 27, 2007, 10:36 AM

Views: 7396
Re: [borov] Match multiple line string

see if one of these FAQs is helpful: