Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Regarding STDOUT and indirect object notation for print

by romandas (Pilgrim)
on Dec 29, 2009 at 21:00 UTC ( #814820=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Regarding STDOUT and indirect object notation for print
in thread Regarding STDOUT and indirect object notation for print

Okay, so even though STDOUT is, by default, a blessed IO::Handle object, and thus possesses the methods described, perl needs to be directed to the IO::Handle module via the 'use' statement so it can find the definitions for those methods. Does that sum it up correctly?


Comment on Re^4: Regarding STDOUT and indirect object notation for print
Re^5: Regarding STDOUT and indirect object notation for print
by ikegami (Pope) on Dec 29, 2009 at 21:52 UTC

    Okay, so even though STDOUT is, by default, a blessed IO::Handle object, and thus possesses the methods described, perl needs to be directed to the IO::Handle module via the 'use' statement so it can find the definitions for those methods. Does that sum it up correctly?

    Unfortunately, it's all wrong.

    • STDOUT isn't blessed. It's not a reference, so it can't be blessed. Globs only act as if they are blessed references.

    • Given a blessed reference or a glob, Perl knows where to look for the methods. For globs, it looks in the IO::Handle namespace.

    • Loading a module doesn't help Perl find anything. It typically loads subroutines. IO::Handle is no exception.

    Perl knows where to look for the method (as indicated by the error message), but there's nothing to find (as indicated in the error message) because IO::Handle wasn't loaded (which isn't indicated in the error message).

      Heh.. not the first time I've been all wrong; likely not the last.

      So, STDOUT is a glob? Of what? My understanding of globs is it's a bunch of filenames, which you can then iterate over to open, close, test, etc. Is that wrong too?

      I'm not sure I follow your logic on the last statement. If, for a glob, Perl will check the IO::Handle namespace, then loading the IO::Handle module will populate that namespace with what Perl needs to find (in this case, the print method), yes? If not, please clarify your statements; I'd appreciate it.
        So, STDOUT is a glob? Of what? My understanding of globs is it's a bunch of filenames, which you can then iterate over to open, close, test, etc. Is that wrong too?

        STDOUT is a Perl type glob, not a file glob. A type glob is related to Perl's built-in and package variables.

        Different kind of glob. Short for type glob, it's the name of the structure used for symbol table entries. Since each symbol name can be used to refer to a scalar, an array, a hash, a function, etc, a typeglob is a structure with a slot for scalar, a slot for an array, ... and a slot for an IO object. You are passing the glob, and the function grabs the associated IO object (or creates it in the case of open).

        If, for a glob, Perl will check the IO::Handle namespace, then loading the IO::Handle module will populate that namespace with what Perl needs to find (in this case, the print method), yes?

        Couldn't have said it better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-07-14 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (256 votes), past polls