Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: !Overriding Builtin print

by demerphq (Chancellor)
on Oct 20, 2003 at 08:05 UTC ( [id://300503]=note: print w/replies, xml ) Need Help??


in reply to !Overriding Builtin print

IIRC some keywords can _only_ be overriden from import. I dont have time to test if print() is one of them, but it may be that if this override is done through the import mechanism in a similar way to which glob is overridden in File::DosGlob that it will work.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Replies are listed 'Best First'.
Re: Re: !Overriding Builtin print
by diotalevi (Canon) on Oct 20, 2003 at 12:59 UTC

    No. You are mistaking ->import() for BEGIN. The point is getting the override information to the parser before it parses the portion you expected to be overridden. ->import() can do that because it happens at BEGIN-time during use(). You can do that yourself with an inline BEGIN block.

      Interesting. However, given the documentation on my system this mistake is not difficult to understand... From perlsub

      Overriding may be done only by importing the name from a module--ordin +ary predeclaration isn't good enough. However, the use subs pragma lets yo +u, in effect, predeclare subs via the import syntax, and these names may +then override built-in ones: use subs 'chdir', 'chroot', 'chmod', 'chown'; chdir $somewhere; sub chdir { ... }

      But thanks for the clarification.


      ---
      demerphq

        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found