[Chapter 7] 7.2.54 SelectSaver - Save and Restore Selected Filehandle
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T02:03:38Z

#

| Chapter 7 The Standard Perl Library |

### 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.

7.2.53 Search::Dict - Search for Key in Dictionary File |  | 7.2.55 SelfLoader - Load Functions Only on Demand