Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Get file part from the section where the matched pattern is found.

by Marshall (Monsignor)
on Nov 30, 2011 at 16:06 UTC ( #940889=note: print w/ replies, xml ) Need Help??


in reply to Get file part from the section where the matched pattern is found.

Something like this should do it (untested).
If the pattern '* disks' can span multiple lines then the solution is more complex. But that looks like a typical set of tokens that would be found on a single line.
#!/usr/bin/perl -w use strict; my $file="show_configuration.out"; open (IN, '<', $file) or die "Can't open $file: $!\n"; my $patternSeen =0; while (<IN>) { $patternSeen =1 if /\*\sdisks/; # '* disks' has been seen next unless $patternSeen; print; }
  • Comment on Re: Get file part from the section where the matched pattern is found.
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2016-07-30 13:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (265 votes). Check out past polls.