1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use strict; use warnings; open my $fh,'>',"test.txt"; close $fh; my $ret = select $fh; select STDOUT; say "'$ret'";
Quote'main::STDOUT'
QuoteOn error, select behaves just like select(2): it returns -1 and sets $!.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#! /usr/bin/env perl use strict; use warnings; use 5.010; open my $fh,'>',"test.txt"; warn "FH: $fh"; close $fh; warn "FH: $fh"; my $ret = select $fh; say "Test to \$fh"; select STDOUT; warn "'$ret'";
1
2
3
4
5
FH: GLOB(0x93d5818) at t.pl line 7.
FH: GLOB(0x93d5818) at t.pl line 10.
say() on closed filehandle $fh at t.pl line 14.
'main::STDOUT' at t.pl line 18.
/code]
2022-02-08T13:00:54 GwenDragonOb/wann die Garbage Collection von Perl sowas später aufräumt, weiß ich nicht.
1 2 3 4 5 6 7 8 9 10 11 12 13
#! /usr/bin/env perl use 5.010; use strict; use warnings; use autodie; my $fh; my $old = select($fh); say 'Ist noch gar nicht offen!'; # say on unopened filehandle $fh open ($fh,'>','test.txt'); say 'Aber jetzt!'; close $fh; say 'Und schon wieder zu.'; # say() on closed filehandle $fh