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

Re: Why use strict is good, and barewords are bad

by jhourcle (Prior)
on Apr 22, 2005 at 00:38 UTC ( #450243=note: print w/replies, xml ) Need Help??

in reply to Why use strict is good, and barewords are bad

But the first one doesn't work okay all the time.

Sure, the month example is always going to fail. (and you can't override a builtin so it works in that context, that I know of) But someone could modify something later, and add a function whose name conflicts with one of your bare words:

perl -e 'sub sat{}; @days = (sun,mon,tue,wed,thu,fri,sat); print "@days\n";'

Or, you use some module that polutes your namespace when you weren't expecting it.

Because Perl scripts aren't compiled, you can't be sure that the assumptions that you made at the time of writing the program (that the barewords weren't names of functions) are going to be true for the life of the script. It also doesn't help that context affects when barewords are always handled as strings:

perl -MData::Dumper -e '$ref->{time()} = time; print Dumper $ref;' perl -MData::Dumper -e '%hash=( time => time ); print Dumper \%hash;'

Replies are listed 'Best First'.
Re^2: Why use strict is good, and barewords are bad
by merlyn (Sage) on Apr 22, 2005 at 01:09 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://450243]
[davido]: ok, on my ubuntu system getlogin grabs from /proc/self/ loginuid (per strace)
[tye]: disable /proc and then see what it does?
[davido]: then it reads from /etc/passwd to decide who my uid is.
[davido]: sorry, typed that before you asked me to disable proc
[davido]: but you stumped me; don't know how to disable proc.
[tye]: I don't know if you can just dismount, but I thought so.
[davido]: yeah, umount -f isn't powerful enough.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2017-06-23 20:03 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (554 votes). Check out past polls.