in reply to exists(&subname) causes strange autovivification problem
Complex things are happening here, and I don't know in which order to untangle them
use strict; use warnings; use feature 'say'; no autovivification; use Data::Dump qw/pp/; my @ary; pp exists $::{non}; pp exists $::{other}; pp exists (&non) ; push @ary, exists (&non) ; say scalar(@ary)
1 # *non exists after compilation of &non "" # *other doesn't exist () # sub &non doesn't exist but empty list returned 0 # @ary has consequently no elements
1 "" "" 1
My guess is that there is actually always an autovivification happening at compile time creating the glob, which has side effects on exists at run time.
I'd say this implementation is buggy!
If you need a workaround, I'd try to first checking if the glob exists before checking the slot and avoiding exists &name
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: exists(&subname) causes strange autovivification problem (workaround)
by LanX (Saint) on Nov 06, 2024 at 01:21 UTC | |
by ikegami (Patriarch) on Nov 06, 2024 at 17:30 UTC | |
|
Re^2: exists(&subname) causes strange autovivification problem
by ysth (Canon) on Nov 06, 2024 at 00:08 UTC | |
by LanX (Saint) on Nov 06, 2024 at 00:17 UTC |