List Info

Thread: perl: Why does this work?




perl: Why does this work?
user name
2007-04-19 21:29:58
I was modelling some ideas with one-off perl code, when I
found this:

perl -e 'use strict; $a="hi"; print
("$an");'

The "use strict" pragma should require that
variables are required to be defined with "my" or
"our" before being accessed. I tried this on a
NetBSD box, two FreeBSD boxes, and a Debian Linux box with
the same results.

Now I know what's going on...

If anybody wants to guess what's going on here, drop me a
note <bharder(at)methodlogic(dot)net> and I'll collect
responses and give the results back to the mailing list
after a day, and post the reason if nobody else got it...

-- 

-bch
http://www.methodlogic.net


Re: perl: Why does this work?
user name
2007-04-21 23:16:11
On Apr 19, 2007, at 19:29, brad harder wrote:

> If anybody wants to guess what's going on here, drop me
a note  
> <bharder(at)methodlogic(dot)net> and I'll collect
responses and  
> give the results back to the mailing list after a day,
and post the  
> reason if nobody else got it...

$a and $b are global variables used for sorting.

Best,

David

Re: perl: Why does this work?
user name
2007-04-22 23:27:19
David E. Wheeler wrote:
> On Apr 19, 2007, at 19:29, brad harder wrote:
> 
>> If anybody wants to guess what's going on here,
drop me a note 
>> <bharder(at)methodlogic(dot)net> and I'll
collect responses and give 
>> the results back to the mailing list after a day,
and post the reason 
>> if nobody else got it...
> 
> $a and $b are global variables used for sorting.
> 
> Best,
> 
> David
> 
Aren't they Main:: package variables? That's what the
warning says about 
   single use of $a when I run the script without the print
statement.

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )