Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Bad news for IO::Handle magic (SWYM or sink)

by Stevie-O (Friar)
on Jul 07, 2004 at 03:35 UTC ( #372261=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: Bad news for IO::Handle magic (SWYM or sink)
Select or Download Code
Re^3: Bad news for IO::Handle magic (SWYM or sink)
by tye (Cardinal) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://372261]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-10-25 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls