On Mon, Dec 27, 2021 at 12:35 PM Ovid via perl5-porters < perl5-porters@perl.org> wrote: > > my @values = (in => "data.csv"); > $values[2]++; > > Except that $values[2] was the string "n/a" and now it's "1". > Huh? $values[2] was undefined. > The core of the idea is simple. it would be lovely to have something to > prevent implicit coercion in a given lexical scope: > > use explicit; > my $num = 3; # integer > $num += .42; # fatal because it creates a float > What am I missing? sub increment_integers_or_die { defined(wantarray()) and croak("increment_integers_or_die called in non-void context"); for my $numb (@_){ /\D/ and die "NOT AN INTEGER: >>>$numb<<<\n"; $numb++; } } -- "Lay off that whiskey, and let that cocaine be!" -- Johnny CashThread Previous | Thread Next