Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > an UN-deprecated way to cvt aryRef to size?

Reply
Thread Tools

an UN-deprecated way to cvt aryRef to size?

 
 
David Combs
Guest
Posts: n/a
 
      04-10-2006

Subject: an UN-deprecated way to cvt aryRef to size?

The line at 792 gives me a deprecated-error:

my $ary1Size = scalar(@{$ary1Ref});

<line 792>: @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!

gives me the warning (I guess it's a warning):

1457 ==/dkcjunk==> perl -wc Dkclib.pm_02
Using an array as a reference is deprecated at Dkclib.pm_02 line 792.
Dkclib.pm_02 syntax OK

DOC-ERROR: The msg is backwards: actually, I'm using a ref as an array.

When I change it to this:

my $ary1Size = scalar(@{$ary1Ref});

# @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!
$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!

I get no such message:

1458 ==/dkcjunk==> perl -wc Dkclib.pm
Dkclib.pm syntax OK
1459 ==/dkcjunk==>


Please, just what *is* the ("new" (as of 5.8.6?)) rule?


And, maybe that rule should be ADDED to the "error msg".


Thanks!

David


 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      04-10-2006

"David Combs" <(E-Mail Removed)> wrote in message
news:e1em87$du9$(E-Mail Removed)...
>
> Subject: an UN-deprecated way to cvt aryRef to size?
>
> The line at 792 gives me a deprecated-error:
>
> my $ary1Size = scalar(@{$ary1Ref});
>
> <line 792>: @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT
> ONCE!
>
> gives me the warning (I guess it's a warning):
>
> 1457 ==/dkcjunk==> perl -wc Dkclib.pm_02
> Using an array as a reference is deprecated at Dkclib.pm_02 line 792.
> Dkclib.pm_02 syntax OK
>
> DOC-ERROR: The msg is backwards: actually, I'm using a ref as an array.
>


No, you're using an array as reference. Change it to:

@{$ary2Ref->[$ary1Ref]} = undef;

The way you wrote it above is equivalent to @{$ary2Ref}->[$ary1Ref].

Matt


 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      04-10-2006

"Matt Garrish" <(E-Mail Removed)> wrote in message
newsfB_f.2545$(E-Mail Removed)...
>
> "David Combs" <(E-Mail Removed)> wrote in message
> news:e1em87$du9$(E-Mail Removed)...
>>
>> Subject: an UN-deprecated way to cvt aryRef to size?
>>
>> The line at 792 gives me a deprecated-error:
>>
>> my $ary1Size = scalar(@{$ary1Ref});
>>
>> <line 792>: @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT
>> ONCE!
>>
>> gives me the warning (I guess it's a warning):
>>
>> 1457 ==/dkcjunk==> perl -wc Dkclib.pm_02
>> Using an array as a reference is deprecated at Dkclib.pm_02 line 792.
>> Dkclib.pm_02 syntax OK
>>
>> DOC-ERROR: The msg is backwards: actually, I'm using a ref as an array.
>>

>
> No, you're using an array as reference. Change it to:
>
> @{$ary2Ref->[$ary1Ref]} = undef;
>


Bad typing on my part, that obviously should have been
@{$ary2Ref->[$ary1Size-1]}

Matt


 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      04-10-2006
David Combs wrote:
> Subject: an UN-deprecated way to cvt aryRef to size?
>
> The line at 792 gives me a deprecated-error:
>
> my $ary1Size = scalar(@{$ary1Ref});


Why are you using the scalar() function?

my $ary1Size = @{ $ary1Ref };

> <line 792>: @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!
>
> gives me the warning (I guess it's a warning):
>
> 1457 ==/dkcjunk==> perl -wc Dkclib.pm_02
> Using an array as a reference is deprecated at Dkclib.pm_02 line 792.
> Dkclib.pm_02 syntax OK


So, it's not the conversion to size that rises the warning?

> DOC-ERROR: The msg is backwards: actually, I'm using a ref as an array.


How is that?

> When I change it to this:
>
> my $ary1Size = scalar(@{$ary1Ref});
>
> # @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!
> $ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT ONCE!
>
> I get no such message:
>
> 1458 ==/dkcjunk==> perl -wc Dkclib.pm
> Dkclib.pm syntax OK
> 1459 ==/dkcjunk==>


So you found a solution. What's the problem, then?

Want an alternative solution?

${ $ary2Ref }[$ary1Size-1] = undef;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      04-10-2006

"Matt Garrish" <(E-Mail Removed)> wrote in message
newsfB_f.2545$(E-Mail Removed)...
>
> "David Combs" <(E-Mail Removed)> wrote in message
> news:e1em87$du9$(E-Mail Removed)...
>>
>> Subject: an UN-deprecated way to cvt aryRef to size?
>>
>> The line at 792 gives me a deprecated-error:
>>
>> my $ary1Size = scalar(@{$ary1Ref});
>>
>> <line 792>: @$ary2Ref->[$ary1Size-1] = undef; # PRE-ALLOCATE IT, ALL AT
>> ONCE!
>>
>> gives me the warning (I guess it's a warning):
>>
>> 1457 ==/dkcjunk==> perl -wc Dkclib.pm_02
>> Using an array as a reference is deprecated at Dkclib.pm_02 line 792.
>> Dkclib.pm_02 syntax OK
>>
>> DOC-ERROR: The msg is backwards: actually, I'm using a ref as an array.
>>

>
> No, you're using an array as reference. Change it to:
>
> @{$ary2Ref->[$ary1Ref]} = undef;
>


I shouldn't post before eating. I thought you were trying to get at the
array. Change that to:

@{$ary2Ref}[$ary1Size-1] = undef;

Matt


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How2 ignore warnings in ASP.NET 2005? Cvt from 2003 tesis ASP .Net 2 10-12-2008 08:08 PM
[OT] Any way to see if a website is up in an automated way? Rhino Java 5 09-05-2006 12:42 PM
way way way OT: MCNGP Announcement Neil MCSE 174 04-17-2006 05:55 PM
AMD Opteron: 1-way, 2-way, ... Up to 8-way. John John Windows 64bit 12 12-27-2005 08:17 AM
What is the best way to make dual-way xml databinding? Stan ASP .Net 3 05-05-2005 02:07 PM



Advertisments