in reply to Pattern Matching
Well, if you just need the line before \nAction, you could try something like:
my @deviceNames = do { open (my $FH, "<", $file) or die "Error: couldn't read '$file': $!\n"; # split up lines by \nAction: within the do-block local $/ = "\nAction:"; my @deviceNames = (); while (my $block = <$FH>) { # extract the last line my $deviceName = ( split(/\n/, $block) )[-1]; push (@deviceNames, $deviceName) if $deviceName; } # while # well, the following line is not really needed, because # $FH is automatically closed at the end of the do-block close ($FH); @deviceNames; } ; # do
or the like (not tested)
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
|
|---|