Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Replace first blank line in a text file with headers.

by Anonymous Monk
on Mar 24, 2016 at 23:13 UTC ( [id://1158763]=note: print w/replies, xml ) Need Help??


in reply to Re: Replace first blank line in a text file with headers.
in thread Replace first blank line in a text file with headers.

Hi, I am using Tie::File, since it seems to be a straight forward way, could someone take a look if there is a better way of doing this?
tie my @array, 'Tie::File', $filename or die "Could not open file '$fi +lename' $!"; # First if the first line does not start with "Name" it means there is +n't any headers, # add headers to the file: unshift @array, 'Name, City, State, Zip' unless $array[0] =~ /Name/; # Check the whole file if there is any blank lines, if there is, get r +id of it @array = grep /\S/, @array; untie @array;
Thank you!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found