Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Perl "new" command

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

in reply to Perl "new" command



is basically just syntactic sugar for:

Foo::bar("Foo", $baz)

with one key exception: in the first example, if the "Foo" package doesn't have a sub called "bar", then the object-oriented concept of inheritance is used to search for it in some other packages.

So in your example, the list of keys accepted by StatView::Script->new can probably be seen by examining the new sub in the StatView::Script package.

Replies are listed 'Best First'.
Re^2: Perl "new" command
by akagrawal3 (Beadle) on Mar 01, 2012 at 10:19 UTC
    Foo::bar("Foo", $baz) what is Foo here. Is it a name of a routine or just a typical scalar value?

      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.

        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().