7 SelectSaver - save and restore selected file handle
14 my $saver = new SelectSaver(FILEHANDLE);
15 # FILEHANDLE is selected
17 # previous handle is selected
20 my $saver = new SelectSaver;
21 # new handle may be selected, or not
23 # previous handle is selected
27 A C<SelectSaver> object contains a reference to the file handle that
28 was selected when it was created. If its C<new> method gets an extra
29 parameter, then that parameter is selected; otherwise, the selected
30 file handle remains unchanged.
32 When a C<SelectSaver> is destroyed, it re-selects the file handle
33 that was selected when it was created.
42 @_ >= 1 && @_ <= 2 or croak 'usage: new SelectSaver [FILEHANDLE]';
44 my $self = bless [$fh], $_[0];
45 select qualify($_[1], caller) if @_ > 1;