start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: 7.2.53 Search::Dict - Search for Key in Dictionary File Chapter 7
The Standard Perl Library
Next: 7.2.55 SelfLoader - Load Functions Only on Demand
 

7.2.54 SelectSaver - Save and Restore Selected Filehandle

use SelectSaver;  select $fh_old; {     my $saver = new SelectSaver($fh_new); # selects $fh_new } # block ends; object pointed to by "my" $saver is destroyed # previous handle, $fh_old is now selected  # alternative invocation, without filehandle argument my $saver = new SelectSaver; # selected filehandle remains unchanged

A SelectSaver object contains a reference to the filehandle that was selected when the object was created. If its new() method is given a filehandle as an argument, then that filehandle is selected; otherwise, the selected filehandle remains unchanged.

When a SelectSaver object is destroyed, the filehandle that was selected immediately prior to the object's creation is re-selected.


Previous: 7.2.53 Search::Dict - Search for Key in Dictionary File Programming Perl Next: 7.2.55 SelfLoader - Load Functions Only on Demand
7.2.53 Search::Dict - Search for Key in Dictionary File Book Index 7.2.55 SelfLoader - Load Functions Only on Demand