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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

Feb 27, 2007, 8:56 AM

Post #1 of 2 (7398 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
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

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

see if one of these FAQs is helpful:;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;;page=unread#unread;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