Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: using strict setup

by nobull (Friar)
on Apr 16, 2005 at 08:57 UTC ( [id://448428]=note: print w/replies, xml ) Need Help??


in reply to using strict setup

You are using Perl4 style libraries. If you are just learning Perl5 you may as well not bother with the old Perl4 approach and go directly to the Perl5 module.

See perlmod and perlmodtut.

As you become more exeperienced in Perl you'll find the are places where the Perl4 library arroach is still valid.

As for use strict, it should in general be the first non-comment line in every Perl source file. The only common exception to this is the first package directive in a .pm file is often placed before the use strict.

You appear to have completely misunderstood what use strict 'vars' does. It does not prevent you using global variables. It prevents Perl from interpreting every mention of an undeclared variable as an implicit package variable declaration. (You should probably avoid using the term "global variable" to describe package variable as global variable means different things to different people.)

There are two ways to declare a package variable in Perl.

our makes a package variable available in the current lexical scoped. As such if you want to share a variable with a Perl4-style library then you need the our in both the files.

The other way is use vars, and this is only needed in one place. (This is really a special case of a variable being exported by a module).

Update: there's no such man page as perlmodtut - I was probably thinking of perlmodstyle or perltoot. (Thanks to tlm).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found