Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Prevent Strings From Being Interpreted As A File Handle

by BrowserUk (Pope)
on Apr 27, 2014 at 10:49 UTC ( #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.


Comment on Re: Prevent Strings From Being Interpreted As A File Handle
Select or Download Code
Re^2: Prevent Strings From Being Interpreted As A File Handle
by amon (Beadle) 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
Node Status?
node history
Node Type: note [id://1083987]
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: (9)
As of 2014-12-26 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls