perlquestion
packetstormer
<p>Hello</p>
<p>I am having a strange problem writing to a file with Tie::File. The code is below. The output to screen writes fine but the actual file isn't change. Its not permissions as I can write to the file fine if I don't split the line. I wonder if there is a fundamental problem with splitting the tie array and editing an element in that?
</p>
<code>
#!/usr/bin/perl
use strict;
use CGI;
use Tie::File;
my $query = new CGI;
#my $file = $query->param('filename');
my $file = '/tmp/test.csv';
my @lines;
print $query->header();
tie @lines, 'Tie::File', $file or die "No file found to work with.";
print "We got $#lines lines in this file";
foreach my $i(@lines) {
my @tmp = split (",",$i);
if($tmp[6] eq "6 Elm") {$tmp[6] = 'XXXXX'}
print "$i\n";
}
untie @lines;
</code>
<p>Does anything look obvious?</p>