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

Re: Perl oddities

by ikegami (Patriarch)
on Mar 01, 2005 at 20:47 UTC ( [id://435606]=note: print w/replies, xml ) Need Help??


in reply to Perl oddities

print FH @list is not unique. It's called the "indirect object" method invocation syntax. The example in perlobj is new Critter ('Barney', 1.5, 70). True, FH is not (necessarily) an object here, but it behaves just like one.

Replies are listed 'Best First'.
Re^2: Perl oddities
by brian_d_foy (Abbot) on Mar 01, 2005 at 21:26 UTC

    I had never really thought of it like that: maybe because we teach it in the second day of Learning Perl and I don't talk about objects and such then. This has also been around a bit longer than

    Too bad this doesn't seem to work.

    #!/usr/bin/perl STDOUT->print( "Hello World!\n" );

    I get this error:

    Can't locate object method "print" via package "IO::Handle" at io.pl l +ine 3.

    If I change it slightly, though, I get the expected output. I'm surprised I didn't get the "perhaps you forgot to load ..." message that usually comes with this sort of error.

    #!/usr/bin/perl use IO::Handle; STDOUT->print( "Hello World!\n" );
    --
    brian d foy <bdfoy@cpan.org>
      I'm surprised I didn't get the "perhaps you forgot to load ..." message that usually comes with this sort of error.

      Odd, I get the message...

      >perl -e "bless({}, 'Cow')->moo();" Can't locate object method "moo" via package "Cow" (perhaps you forgot + to load "Cow"?) at -e line 1. >perl -e "STDOUT->print();" Can't locate object method "print" via package "IO::Handle" (perhaps y +ou forgot to load "IO::Handle"?) at -e line 1. >perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 633 provided by ActiveState Corp. http://www.ActiveState. +com Built 21:33:05 Jun 17 2002

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-03-28 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found