On 20/01/2011 19:10, steve1040 wrote:

Using the script below I need to add a second line with the following
text:
"STAGEHDR|Barcoded"

#!perl
use strict;
use warnings;
my $file = 'path/to/Access.csv';
my $newline = "ENTHDR|1|3.0";
{
    local @ARGV = ($file);
    local $^I = '.bac';
    while(<>){
       if ($. == 1) {
          print "$newline$/";
       }
       else {
          print;
       }
    }
}

Hi Steve

You seem to have ignored the help you were offered when you last posted this problem. The code you have here (apart from the misgivings that Shlomi has expressed) will /replace/ the first line of the input file with the given string. Is that what you want, or do you need to add (prepend) them as you said previously? You have already been shown code that will do the latter; do you need a different solution?

- Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to