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

Re^2: Perl oddities

by brian_d_foy (Abbot)
on Mar 01, 2005 at 21:26 UTC ( #435620=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl oddities
in thread Perl oddities

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>


Comment on Re^2: Perl oddities
Select or Download Code
Re^3: Perl oddities
by ikegami (Pope) on Mar 01, 2005 at 22:24 UTC
    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
Node Status?
node history
Node Type: note [id://435620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-07-22 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (113 votes), past polls