an UN-deprecated way to cvt aryRef to size?

D

David Combs

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
 
M

Matt Garrish

David Combs said:
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
 
M

Matt Garrish

Matt Garrish said:
David Combs said:
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
 
G

Gunnar Hjalmarsson

David said:
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;
 
M

Matt Garrish

Matt Garrish said:
David Combs said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top