Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The :: in perl

Status
Not open for further replies.

be12dune09a

Programmer
Nov 17, 2005
24
RO
I read the perltoot but I diden't understand what :: does in for exemple $Person::Something What is Something? A static member of the class Person or a variable that is particular for each object and can be used directly without any method call.
 
It's known as a package variable in Perl. It's pretty much the same as what a static variable does in Java.
 
ok than if I use a variable without my it also the same as a static variable in Java?
 
It's good practice to enable strict checking, which forces you to declare variables with `my' or `our', unless you're using the $Person::Something syntax for package variables you've mentioned above.

If you're not using strict, then yes: using a variable without pre-declaring what scope you want it to have will result in a package variable being created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top