Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Tie::File doesn't save

by planetscape (Canon)
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

HTH,

planetscape


Comment on Re: Tie::File doesn't save
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://913192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2015-07-08 06:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls