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!