I'm having a problem with the script below.  I want to alter just the 
first line of a CSV file, removing the prefix "tag_" from each value in that 
line.  However, because the new line is shorter than the original, the script 
is only over-writing part of the original line (exactly the number of 
characters  of the new line).

        Is there a way to replace the entire line with the new, shorter one?

Thanks,
Frank

use strict;
use warnings;

my $filename = 'products.csv';
open (my $fh, '+<', $filename) || die "can't open $filename: $!";
my $line = <$fh>;
$line =~ s/tag_//gi;
seek $fh, 0, 0;
printf {$fh} $line;
close $fh;

http://www.surfshopcart.com/
Setting up shop has never been easier!


--
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