develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991121.001] Inaccuracy in perldiag

Thread Previous
From:
Sean McAfee
Date:
November 30, 1999 11:15
Subject:
Re: [ID 19991121.001] Inaccuracy in perldiag
Message ID:
199911301915.OAA05185@waits.facilities.med.umich.edu
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>On Sun, Nov 21, 1999 at 04:52:21AM -0500, Sean McAfee wrote:
>> The perldiag man page includes the following paragraph:

>>      Can't use an undefined value as %s reference
>>          (F) A value used as either a hard reference or a
>>          symbolic reference must be a defined value.  This helps
>>          to delurk some insidious errors.

>> In fact, it appears that this is only a fatal error when strict refs is in
>> effect.  It's not an error at all, otherwise.

>~> perl
>no strict;
>undef->[1];
>Can't use an undefined value as an ARRAY reference at - line 2.

Guess I should have included a code sample.  Sorry about the oversight.

bash-2.03$ perl -le '$x = undef; print @$x'

bash-2.03$ perl -le 'use strict; my $x = undef; print @$x'
Can't use an undefined value as an ARRAY reference at -e line 1.
bash-2.03$ 

Here's the essential part of the code which originally brought the behavior
to my attention:

use strict;
my (@result, %id, %dup);

%id  = ( 1 => 'a', 2 => 'b', 3 => 'c');
%dup = ( 2 => [ 'x', 'y', 'z' ] );

@result = map +($id{$_}, @{ $dup{$_} }), 1, 2, 3;

I got the above error until I preceded the last line with "no strict 'refs'".

-- 
Sean McAfee | GCS d->-- s+++: a27 C++ US+++ P+++$ L++ E- W+ N++ |
            | K w--- O? M- V-- PS+ PE Y+ PGP?>++ t+() 5++ X R+  | mcafee@
            | tv+ b++ DI++ D+ G e++ h r---* y+>++               | umich.edu

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About