Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: doing something with the rest of a file after matching a keyword

by krujos (Curate)
on Jan 17, 2003 at 16:50 UTC ( #227725=note: print w/ replies, xml ) Need Help??


in reply to doing something with the rest of a file after matching a keyword

You could just set a flag and save when that is true.
my $flag = false; my @saved #the saved portion of the file while (<FILE>) { #set the flag to true when we find the word Well if (/Well/) { $falg = true; } if ( $falg ) { push @saved, $_; #$_is the current line in your file } }
  • Comment on Re: doing something with the rest of a file after matching a keyword
  • Download Code

Replies are listed 'Best First'.
Re: Re: doing something with the rest of a file after matching a keyword
by davorg (Chancellor) on Jan 17, 2003 at 17:01 UTC

    That's far too complex.

    my @saved; while (<FILE>) { @saved = <FILE> if /Well/; }
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2016-06-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (370 votes). Check out past polls.