http://www.perlmonks.org?node_id=372261


in reply to Re: Bad news for IO::Handle magic (SWYM or sink)
in thread Bad news for IO::Handle magic

While my examples always used STDIN, that was for brevity. Any code can play tricks on you if you use the Module->sub() OO syntax.
$ perl -MCGI -le 'select(select(CGI)); print CGI->new' Can't locate object method "new" via package "IO::Handle" at -e line 1 +.
This isn't limited to all-caps names, either:
perl -MFile::Spec -le 'select(select(File::Spec)); print File::Spec->r +ootdir' Can't locate object method "rootdir" via package "IO::Handle" at -e li +ne 1.
--Stevie-O
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

Replies are listed 'Best First'.
Re^3: Bad news for IO::Handle magic (SWYM or sink)
by tye (Sage) on Jul 07, 2004 at 03:43 UTC

    I said not to use bareword file handles. Using mixed-case bareword file handles is an even worse idea and you deserve any grief you cause yourself if you do that.

    Though, with other problems, I'm starting to think "File::Spec"->method() is the better syntax. But more than that I prefer putting the module's factory (which for many modules is simply the module's name) into a scalar, even better if this can be done as part of the use or require for the module.

    - tye        

Re^3: Bad news for IO::Handle magic (SWYM or sink)
by ysth (Canon) on Jul 07, 2004 at 15:37 UTC
    I'm curious to know how you found the select select trick.
      Stolen^WBorrowed straight outta Symbol's geniosym:
      sub geniosym () { my $sym = gensym(); # force the IO slot to be filled select(select $sym); *$sym{IO}; }
      --Stevie-O
      $"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc