Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Prevent Strings From Being Interpreted As A File Handle

by BrowserUk (Patriarch)
on Apr 27, 2014 at 10:49 UTC ( [id://1083987]=note: print w/replies, xml ) Need Help??


in reply to Prevent Strings From Being Interpreted As A File Handle

The simple solution is to stop calling a subroutine as a method and just use: Input::awesome;.

Or, if awesome really is a method, then invoke it via a reference blessed into the class 'Input':

$o = bless [], 'Input';; ... $o->awesome;; Yay!

Or, as you've pointed out, use lexicals.

Bottom line: stop going out of your way to artificially create problems.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Prevent Strings From Being Interpreted As A File Handle
by amon (Scribe) on Apr 27, 2014 at 11:54 UTC

    Thank you for coming up with the instance workaround.

    However, I am not trying to prevent this ambiguity, but to resolve it in a specific way (i.e. I'm seeking Perl wisdom, not trying to solve the immediate problem which I'm already mitigating using other means). In general, Perl is flexible enough to change such core behavior, and I would like to find out how this can be done. I was very careful to word my question as “How can I disambiguate a method call on a string so that it is always resolved as a class method call, and not as a call on an IO instance?” – both “method call” and “string” are central to my question.

      both “method call” and “string” are central to my question.

      I covered your objections with my last sentence: Bottom line: stop going out of your way to artificially create problems.

      Even if you succeed in finding a way to subvert Perl into doing this stupid thing; it won't stop it being stupid.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found