develooper Front page | perl.perl5.porters | Postings from April 2001

Re: [ID 20010329.005] symbolic refs allowed for defined and use strict

Thread Previous
From:
Abigail
Date:
April 1, 2001 05:29
Subject:
Re: [ID 20010329.005] symbolic refs allowed for defined and use strict
Message ID:
20010401123442.12818.qmail@foad.org
On Thu, Mar 29, 2001 at 01:39:03PM -0500, Chris Nandor wrote:
> This is a bug report for perl from pudge@pobox.com,
> generated with the help of perlbug 1.28 running under perl v5.6.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> This should, I believe, according to my own reasoning and to the
> documentation, not print 1, but die because of symbolic refs
> being used with strict refs enabled:
> 
> perl -wle 'use strict; sub foo { 2 } my $op = "oo"; print defined &$op;'
                                                 ^^
> 
> "print &$op" fails appropriately, of course.


I guess you meant ``my $op = "foo"'' here. But that raises an interesting
question. What should ``defined &$op;'' do if $op equals "oo"? Die as well,
because use strict is in use?

Note that it isn't just &$op, all the following are all legal perl:

    perl -we 'use strict; my $op; print defined $$op'

    perl -we 'use strict; my $op; print defined @$op'

    perl -we 'use strict; my $op; print defined %$op'

Or even:

    perl -we 'use strict; print defined ${"foo"}'



Abigail

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