Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Perl "new" command

by tobyink (Abbot)
on Mar 01, 2012 at 11:31 UTC ( #957177=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl "new" command
in thread Perl "new" command

The first Foo is the name of a package, as in...

package Foo; sub bar { print "Inside the package, I am called 'bar'\n"; print "But outside the package, I am called Foo::bar\n"; }

The second "Foo" is just a string scalar.

I really think you need to read perlboot from start to finish.

Replies are listed 'Best First'.
Re^4: Perl "new" command
by JavaFan (Canon) on Mar 01, 2012 at 11:42 UTC
    In that example, the sub can be called as Foo::bar() regardless whether you are inside or outside the package. It's just that inside the package, the sub can also be called as bar().

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2016-07-01 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (14 votes). Check out past polls.