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

Re: strip until blank line

by kilinrax (Deacon)
on Nov 23, 2000 at 00:04 UTC ( [id://43008]=note: print w/replies, xml ) Need Help??


in reply to strip until blank line

This will strip all the lines preceeding the blank one:
my @data = <FILE>; while( $data[0] =~ /\S/ ) { shift @data; } print @data;
Update:
Just spotted quidity's post after fixing the error (d'oh), and the second point he raises is a good one; the following code would be better if you're reading from a file (the above code was designed to work whether you were working with data in a file or array, as you did not specify which you were dealing with):
while( $line = <FILE> ) { last unless $line =~ /\S/; }
which will leave you with FILE at the first line after the blank one.

Replies are listed 'Best First'.
Re: Re: strip until blank line
by quidity (Pilgrim) on Nov 23, 2000 at 00:10 UTC

    This will not work, as you are not shifting from what you think. Shift defaults to @_ or @ARGV depending on your current scope. You want to use:

     shift @data;

    which you now have. You don't really though, as this solution (as a whole) requires you to read the entire file into memory, which could be a bad thing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found