$# is no longer supported
$# is no longer supported
am 20.09.2011 17:38:42 von David Jacopille
To get highest index number on an array you use:
$#array
Doing this on an arrayref:
$#{arrayref}
I get a warning "$# is no longer supported". The program does continue.
Apparently $# and $* were deprecated in regular expression context and that e=
rror message exactly is documented in CPAN.
Seems like a bug in Perl (5.10.0), but perhaps I could be doing something to=
make Perl believe I'm trying to use the deprecated $# regular expression va=
riable.
Any ideas on how I can remove the ambiguity and the warning?
Thanks,
Dave=
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: $# is no longer supported
am 20.09.2011 17:44:19 von Shawn H Corey
On 11-09-20 11:38 AM, David Jacopille wrote:
> To get highest index number on an array you use:
>
> $#array
>
> Doing this on an arrayref:
>
> $#{arrayref}
Try:
$#{$arrayref}
>
> I get a warning "$# is no longer supported". The program does continue.
>
> Apparently $# and $* were deprecated in regular expression context and that error message exactly is documented in CPAN.
>
> Seems like a bug in Perl (5.10.0), but perhaps I could be doing something to make Perl believe I'm trying to use the deprecated $# regular expression variable.
>
> Any ideas on how I can remove the ambiguity and the warning?
>
> Thanks,
> Dave
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
"Make something worthwhile." -- Dear Hunter
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: $# is no longer supported
am 20.09.2011 17:50:54 von Uri Guttman
>>>>> "DJ" == David Jacopille writes:
DJ> To get highest index number on an array you use:
DJ> $#array
DJ> Doing this on an arrayref:
DJ> $#{arrayref}
that is a bareword and not an array ref. so perl is parsing $# as the
deprecated builtin variable
DJ> I get a warning "$# is no longer supported". The program does
DJ> continue.
DJ> Apparently $# and $* were deprecated in regular expression context
DJ> and that error message exactly is documented in CPAN.
these work fine:
perl -lwe '$x = [1,2]; print $#$x'
1
perl -lwe '$x = [1,2]; print $#{$x}'
1
uri
--
Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com --
------------ Perl Developer Recruiting and Placement Services -------------
----- Perl Code Review, Architecture, Development, Training, Support -------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: $# is no longer supported
am 20.09.2011 18:48:36 von Leo Lapworth
--0015174be31042a7f704ad623c9a
Content-Type: text/plain; charset=ISO-8859-1
Hi,
On 20 September 2011 16:50, Uri Guttman wrote:
> >>>>> "DJ" == David Jacopille writes:
>
> DJ> I get a warning "$# is no longer supported". The program does
> DJ> continue.
>
> DJ> Apparently $# and $* were deprecated in regular expression context
> DJ> and that error message exactly is documented in CPAN.
>
> these work fine:
>
> perl -lwe '$x = [1,2]; print $#$x'
> 1
> perl -lwe '$x = [1,2]; print $#{$x}'
> 1
>
I usually find I want the size (instead of the index):
perl -lwe '$x = [1,2]; print scalar(@{$x});'
2
or last element in the array:
perl -lwe '$x = ["a","b"]; print $x->[-1];'
b
Might not be relevant here but thought I'd mention them just incase.
Leo
--0015174be31042a7f704ad623c9a--