For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2006 > Re: #$ary ???









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: #$ary ???
Dr.Ruud

2006-04-28, 7:58 am

Dr.Ruud schreef:

> Why gamble that "0" is a valid index, or even the minimal index, if
> there is "$["?
>
> Of course "the others" should use a local "$[" if they change it from
> the default 0 to some other value, but you just can't be sure that it
> will never bite you. Unless you use "$[" with "$#ary", because "$#ary"
> depends on "$[" like this: ($#ary -$[ +1) == scalar(@ary).


I totally overlooked that $[ is file-based (Perl 5), which means that
there are no "others".

perldoc perlvar [...]
As of release 5 of Perl, assignment to $[ is treated as a com-
piler directive, and cannot influence the behavior of any other
file. (That's why you can only assign compile-time constants
to it.) *Its use is highly discouraged.* [...]

--
Affijn, Ruud

"Gewoon is een tijger."


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com