home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Perl CookbookPerl CookbookSearch this book

8.10. Removing the Last Line of a File

8.10.2. Solution

Use the standard (as of v5.8) Tie::File module and delete the last element from the tied array:

use Tie::File;

tie @lines, Tie::File, $file        or die "can't update $file: $!";
delete $lines[-1];


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.