Name

new

Synopsis

$saver = new SelectSaver[(fh)]

Constructor. Creates a new SelectSaver object, $ saver, which saves the current filehandle. The optional parameter fh is the filehandle that will temporarily replace the current filehandle. If fh is present, the current filehandle is saved in $ saver, and the new one becomes the current filehandle. With no parameter, the current filehandle is saved in the object $ saver, and it remains current.

You can use the newly selected filehandle within the current block. When you exit the block, the previous filehandle is again made the current one, and the SelectSaver object in which it was stored is destroyed.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.