SelectSaver(3perl)

πŸ’– NAME πŸ’–

SelectSaver β€” bestie, it saves your selected file handle and then restores it, no cap ✨


πŸŽ€ SYNOPSIS πŸŽ€

use SelectSaver;

{
   my $saver = SelectSaver->new(FILEHANDLE);
   # FILEHANDLE is selected
}
# previous handle is selected

{
   my $saver = SelectSaver->new;
   # new handle may be selected, or not
}
# previous handle is selected

🌸 DESCRIPTION 🌸

Okay so picture this: a SelectSaver object is literally holding a reference to the file handle that was selected back when it got created. That's its whole thing. That's its moment. πŸ’…

When its new method gets an extra parameter? Boom β€” that parameter is the one that gets selected. But if you don't hand it an extra parameter, then the currently selected file handle just... stays exactly as it was. No changes, no drama, we leave it alone fr fr. πŸ¦‹

And here's the glow-up moment: the second a SelectSaver gets destroyed, it re-selects the file handle that was selected when it was created. The way that it just... remembers for you. Iconic behavior honestly. πŸ‘‘


this page is from perl v5.44.0, dated 2026-10-17, and it's filed under SelectSaver(3perl) β€” mwah, go restore a file handle bestie, you got this 🫢✨

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms