perl -e "sub IO::Handle::DESTROY { print("""destroying $_[0]\n""") } $a=bless([]);" #### destroying IO::Handle=IO(0x18214b0) destroying IO::Handle=IO(0x1821570) destroying IO::Handle=IO(0x18215dc) #### sub IO::Handle::DESTROY { !$IO::Handle::i++ and print($_); } # Abracadra, Associat STDIN, STDOUT and STDERR with IO::Handle. $anyvar = bless([]); $_ = "Just another Perl hacker.\n"; # IO::Handle::DESTROY is now called for STDIN, STDOUT and STDERR.