Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Tie::File doesn't save

by planetscape (Chancellor)
on Jul 07, 2011 at 13:55 UTC ( #913192=note: print w/replies, xml ) Need Help??

in reply to Tie::File doesn't save

They are visible if i print all the array but when i untie it, records are not saved...

Also insure you are using the correct recsep for your filesystem.

On Windows, I needed:

use Fcntl 'O_RDWR'; use Tie::File; my $file = "./filename.ext"; tie (my @lines, 'Tie::File', $file, mode => O_RDWR,
recsep => "\n"
) or die "Can't update $file: $! "; shift @lines; (tied @lines)->flush; untie @lines;

for Strawberry Perl (This is perl, v5.10.0 built for MSWin32-x86-multi-thread).

While on the same system, using Cygwin Perl (This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int), this did the trick:

use Fcntl 'O_RDWR'; use Tie::File; my $file = "./filename.ext"; tie (my @lines, 'Tie::File', $file, mode => O_RDWR) or die "Can't upda +te $file: $! "; shift @lines; (tied @lines)->flush; untie @lines;

Both were operating on the same file, which file described as:

$ file filename.ext filename.ext: ASCII text



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://913192]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-06-27 03:11 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (598 votes). Check out past polls.