warpod has asked for the wisdom of the Perl Monks concerning the following question:
What is wrong with this code?
print() on unopened filehandle F at test.pl line 7.
but if I move fopen and fclose into test.pl, then this code
when executed it says:==== test. pl ====== #!/usr/bin/perl use strict; use mmm; local* F; mmm::fopen(F, ">tst"); print F "hi"; mmm::fclose F; ==== mmm.pm ====== #!/usr/bin/perl use strict; package mmm; BEGIN {} sub fopen(*;$) { local *FH = $_[0]; return CORE::open(FH, $_[1]); } sub fclose(*) { local *FH = $_[0]; return CORE::close(FH); } END { } 1;
print() on unopened filehandle F at test.pl line 7.
but if I move fopen and fclose into test.pl, then this code
works just fine. What is wrong in package?local* F; fopen(F, ">tst"); print F "hi"; fclose F;
Back to
Seekers of Perl Wisdom