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.
Thank you!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;
|
|---|