Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^6: perl 5.12 BSD portability (CPAN test result)...print

by perl-diddler (Chaplain)
on Mar 15, 2013 at 21:29 UTC ( #1023781=note: print w/replies, xml ) Need Help??

in reply to Re^5: perl 5.12 BSD portability (CPAN test result)...print
in thread perl 5.12 BSD portability (CPAN test result)...print

Ah...I thought it was just an indirect method call...didn't know it was it's own special operator... Does it still have to be it's own special operator? I.e. are there places where the indirect method call wouldn't give the same behavior? (Apparently there were in the past, but what about now?)....
  • Comment on Re^6: perl 5.12 BSD portability (CPAN test result)...print

Replies are listed 'Best First'.
Re^7: perl 5.12 BSD portability (CPAN test result)...print
by ikegami (Pope) on Mar 16, 2013 at 18:35 UTC

    Assuming you're ok with breaking every program that does print $x, how would you implement IO::Handle::print without the print operator?

    There are other issues, but they're not worth mentioning after the above two.

      Um, I suppose I'm not sure I see the difference between a method called print, called indirectly, that appears to do the same thing as C<print> the operator.

      Could you explain the difference to someone to whom it is not obvious? ;-)

        Without an explicit filehandle, where does the output of print $x go? How is Perl to tell the difference between "print the contents of $_ to the filehandle in $x" from "print the contents of $x to the currently selected filehandle"?

        So you want me to explains how it's impossible to write the method without the print operator? Well, why don't you try it.

        Or are you asking me to explain why they don't do the same thing? Well, consider

        >perl -le"$x = 'abc'; print $x;" abc

        As you can see, it doesn't call the method $x of class abc. If it was an indirect method call, it would have the following outcome:

        >perl -le"$x = 'abc'; $x->print;" Can't locate object method "print" via package "abc" (perhaps you forg +ot to load "abc"?) at -e line 1.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-10-24 06:46 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (242 votes). Check out past polls.