What is it that prohibits assignment in loop to work when combined with declaration (
my)? Why can't perl just DWIM (which is to set
$i = 3 in both examples below)?
$ perl -l
use strict;
use warnings;
my $i = undef;
$i = $_ for (1 .. 3);
($i) ? print $i : warn "pre-defined - missing";
my $j = $_ for (1 ..3);
($j) ? print $j : warn "direct - missing";
__END__
3
direct - missing at - line 9.
I just wonder since, after all, it
does what I mean without
warnings and
my:
$ perl -l
$j = $_ for (1 ..3);
($j) ? print $j : warn "no warnings - missing";
__END__
3
For the record:
This is perl, v5.8.5 built for i386-linux-thread-multi
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]