Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by chromatic (Archbishop)
on Mar 14, 2013 at 06:14 UTC ( #1023381=note: print w/ replies, xml ) Need Help??


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

Um... so everyone who uses 'print' or 'printf' needed to use IO::Handle?

Everyone who wanted to use those as methods on filehandles had to use IO::Handle, yes.


Comment on Re^3: perl 5.12 BSD portability (CPAN test result)...print
Re^4: perl 5.12 BSD portability (CPAN test result)...print
by perl-diddler (Hermit) on Mar 14, 2013 at 10:51 UTC
    But only in the FH->print format? Why does it work in the print FH mode? Aren't they supposed equivalent?

      The parser knows about print as a keyword. It's been a special case as far back as I can remember (Perl 1?). You can look at it as an indirect method call from the language level, but the parser doesn't need heuristics because the grammar has a specific rule for the print $filehandle case.

      But only in the FH->print format? Why does it work in the print FH mode? Aren't they supposed equivalent?

      No, they're not equivalent. print FH ... is an instance of a the print operator.

      FH->print(...) is a method call. It does whatever FH's class's print method does. If FH is an IO::Handle or IO::File object, its print method calls the print operator.

      sub print { @_ or croak 'usage: $io->print(ARGS)'; my $this = shift; print $this @_; }
        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?)....

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023381]
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: (7)
As of 2014-12-28 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (182 votes), past polls