in reply to popping or shifting a line off a file
#!/usr/bin/perl -w use strict; my $passwords = 'passwords'; my $rec_size = 9; my $password; open PASS, "+<$passwords" or die "Error message here $!"; # Seek from end of file seek PASS, -$rec_size, 2; # Store the position of the last seek my $last = tell PASS; # Read the password but not the newline read PASS, $password, $rec_size -1; # Remove the record just read truncate PASS, $last; close PASS; print $password, "\n"; __END__
This method will be significantly faster than the method shown above.
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: popping or shifting a line off a file
by nmerriweather (Friar) on Jul 29, 2002 at 20:36 UTC |