On Wed Sep 01 10:29:40 2004, andrew@pimlott.net wrote: > > > > I tried to write a wrapper for open: > > sub myopen (*$$) { > my ($fh, $mode, $file) = @_; > open($fh, $mode, $file) > } > > However, using it has unexpected and subtle side effects on how the > opened > filehandle is interpreted by the parser. > > myopen OUT, '>', 'out' or die $!; > print OUT "hey\n"; > close OUT; > > works fine. But > > sub FOO::bar { "hey\n" } > myopen OUT, '>', 'out' or die $!; > print OUT FOO->bar; > close OUT; > > gives Can't locate object method "OUT" via package "FOO", and with -w > also > gives Name "main::OUT" used only once: possible typo. This code works > fine > with a normal open. > [snip] I believe the program attached, 31442.pl, reproduces your sample code. However, when I run it I don't reproduce either the failure or the warning you cite. (Of course, when I try to run this under 'use strict;', I start to encounter problems. But, then again, I don't understand the need to write a wrapper for 'open'. And it's been a long time since I wrote a program with global filehandles rather than lexically scoped filehandles.) Thank you very much. Jim KeenanThread Previous | Thread Next