Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Built-in functions and symbol table

by gildir (Pilgrim)
on Jun 06, 2001 at 13:30 UTC ( [id://86153]=perlquestion: print w/replies, xml ) Need Help??

gildir has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I have a package Foo with function sub delete {...}. In this function I want to call built-in perl function delete for deleting an element of hash. How do I do this? I found that I should use CORE::delete.

I tought that I know how Perl symbol tables work, but now I'm confused. Where does perl build-in functions 'live'? In every package symbol table? I suppose not.
I guess they live in CORE package's symbol table. So how they are called if they are not exported to every symbol table? Are they treated as a reserved words in perl? And if they are, why I'm allowed to define my function delete in my package?

Or maybe I've got it all wrong.

Replies are listed 'Best First'.
Re (tilly) 1: Built-in functions and symbol table
by tilly (Archbishop) on Jun 06, 2001 at 16:08 UTC
    Rules are for users. :-)

    Built in functions are exactly that, built in. Try calling them with an & and you will fail. If you have a regular function with the same name, the built-in takes precedence unless the regular one was imported into the current package. (See perlsub's section on overriding builtin functions for more.) Even then it only works if the function is in a list of things that can be overridden.

    If it seems strange to you that something so important is not in the symbol table, neither are lexical variables...

Re: Built-in functions and symbol table
by Beatnik (Parson) on Jun 06, 2001 at 13:59 UTC
    What about $self->delete(); vs delete(); ?

    The overload POD might get you some hints, altho technically it's not overloading :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found