On Wed, 2008-08-27 at 16:54 -0500, STEVEN WHALEY wrote:
> and make each line an entry in an array. I do not actually need the
> first two lines, but I can pop them off so grabbing them isn't a
> problem. I can get a regex to match the "Folder Path:..." line but
> I'm
> not sure how to get the rest of the section, up to the next empty
> line,
> into an array.
>
>
> Can anyone help?
You can do this two ways: one with a multi-line regex; the other with a
Finite-State Automation (FSA).
With regex:
# Slurp everything in a scalar, say $contents
$contents =~ /Folder Path: '[Win_Prod_1] ag-bartend-srv\/'(.*?)Folder Path/ms;
$lines = $1;
@lines = split /\n/, $lines;
with FSA:
my $state = 0;
while( <> ){
chomp;
if( /Folder Path: '[Win_Prod_1] ag-bartend-srv\/'/ ){
$state = 1;
}elsif( /Folder Path/ ){
$state = 0;
}elsif( $state == 1 ){
push @lines, $_;
}
}
See `perldoc perlretut` and `perldoc perlre` for more information on
regular expressions.
--
Just my 0.00000002 million dollars worth,
Shawn
"Where there's duct tape, there's hope."
Cross Time Cafe
"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/