in reply to Matching Across Lines
You need to use the /m modifier so that ^ can match the start of lines within your string. Otherwise it just matches the start of your string and not lines within it. Also, you might want to use the /x modifier so that you can comment your RE a little bit. Here's a snippet for you to modify as is your wont:
Update: Some other notes. I'm not sure why you're using local *FH; but if you have a modern perl, you can do something like this instead:#!/usr/bin/perl -l $text = do { local $/; <DATA> }; print $1 if $text =~ / ^Total\s+Datafile\s+Size\s+MB\s* # header ^-+\s* # separator ^([\d.]+) # the number I want /mix; __DATA__ Total Datafile Size MB ---------------------- 73602.1406 Total Database Size MB ---------------------- 48107.7656 Total Free Space MB ------------------- 25462.8125
open(my $fh, $file_name) or die; my $text = do { local $/; <$fh> }; # slurp close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Matching Across Lines
by mkb125 (Initiate) on Feb 25, 2004 at 18:43 UTC | |
by mkb125 (Initiate) on Feb 25, 2004 at 19:37 UTC |