develooper Front page | perl.perl5.porters | Postings from October 2008

Why are "Scalar value better written as" warnings not thrown for arrayrefs?

Thread Next
From:
Chas. Owens
Date:
October 31, 2008 06:02
Subject:
Why are "Scalar value better written as" warnings not thrown for arrayrefs?
Message ID:
58ce48dc0810310602u38cedd26ja1eb51b252af5f3c@mail.gmail.com
I noticed today that no warning is thrown when a reference is used in
a slice of one element, is there a reason for this?  I tested with
both 5.8.8 and 5.10.0.

#!/usr/bin/perl

use strict;
use warnings;

my @a = qw/a b c/;
print @a[0], "\n";

my $ref = \@a;
print @{$ref}[0], "\n";

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Thread Next


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