packetstormer has asked for the wisdom of the Perl Monks concerning the following question:
Hello
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?
#!/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;
Does anything look obvious?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie::File Write Problem
by toolic (Bishop) on Nov 17, 2011 at 19:30 UTC | |
by packetstormer (Monk) on Nov 17, 2011 at 19:32 UTC | |
by toolic (Bishop) on Nov 17, 2011 at 19:57 UTC | |
by jethro (Monsignor) on Nov 17, 2011 at 23:35 UTC | |
by packetstormer (Monk) on Nov 18, 2011 at 08:35 UTC |