in reply to problem unless I use ".="
It's because the value of $baseball{mets} is not defined at the point you're trying to use it.
Note how the warning goes away with something like:
my $yanks = $baseball{yankees} || ""; my $mets = $baseball{mets} || ""; if ( $baseball{yankees} = $yanks.$mets ) { foreach $_ (keys %baseball) { print "$_ => $baseball{$_}\n"; } }
You could also do it this way:
if ( $baseball{yankees}=($baseball{yankees} || ""). ($baseball{mets} | +| "") ) { foreach $_ (keys %baseball) { print "$_ => $baseball{$_}\n"; } }
This is all assuming, of course, that you really mean to do the assignment $baseball{yankees}=$baseball{yankees}.$mets.
If instead you are doing a comparison, you'd probably want to use eq (for string comparisons) rather than == (for numerical comparisons).
|
---|