Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Delete last record in text file

by CukiMnstr (Deacon)
on Aug 18, 2003 at 17:32 UTC ( #284655=note: print w/replies, xml ) Need Help??


in reply to Delete last record in text file

you can also use Tie::File:
#!/usr/bin/perl -w use strict; use Tie::File; my $filename = 'file.txt'; tie my @data, 'Tie::File', $filename or die "couldn't tie(): $!"; pop @data; untie @data;

hope this helps,

Replies are listed 'Best First'.
Re: Re: Delete last record in text file
by wirrwarr (Monk) on Aug 18, 2003 at 18:14 UTC
    Tie::File seems to be rather slow on large files. I tried the Tie::File and (open file, read in all lines, pop, write back) variants on a ~5M file, and the second was about 10 times faster.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2020-02-26 20:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (117 votes). Check out past polls.

    Notices?