Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Now.... I want to put the filename in a variable, $file, so that I can change the name through the variable if necessary. I now have this code:#!/usr/bin/perl -w use strict; my $count=8; use Tie::File; tie my @lines, 'Tie::File', 'T:\temp.txt' or die 'tie failed'; unshift @lines, "$count"; untie @lines;
Which unfortunately doesn't work. I get the following error:#!/usr/bin/perl -w use strict; my $file="T:/temp/temp.txt"; my $count=8; use Tie::File; tie my @lines, 'Tie::File', "$file" or die 'tie failed'; unshift @lines, "$count"; untie @lines;
And.... line 9 just happens to be where I am doing the file tie to the array. I did indeed verify that the file still exists and the permissions are OK. I checked in the CPAN documentation for this module, and from what I saw in it this line:tie failed at P:\test405.pl line 9
.... should indeed work. What finite subtlety am I missing here? I am figuring that the problem must be right under my nose and I am simply missing it.tie my @lines, 'Tie::File', "$file" or die 'tie failed';
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Tie::File Help
by deibyz (Hermit) on Apr 27, 2005 at 13:30 UTC | |
by Anonymous Monk on Apr 27, 2005 at 13:47 UTC | |
by deibyz (Hermit) on Apr 27, 2005 at 13:54 UTC | |
Re: Tie::File Help
by polettix (Vicar) on Apr 27, 2005 at 13:11 UTC | |
by Anonymous Monk on Apr 27, 2005 at 13:22 UTC | |
by polettix (Vicar) on Apr 27, 2005 at 13:26 UTC | |
Re: Tie::File Help
by bofh_of_oz (Hermit) on Apr 27, 2005 at 13:49 UTC |