[sf-perl] Odd behavior for dot operator?

Andrew Sigmund ASIGMUND at altera.com
Thu Mar 17 22:55:58 PDT 2011


First, I realize that I can (& should) use "join" for something like this, and "join" behaves as I expect here. Nevertheless, I'm interested to get an explanation for this behavior:

(v5.12.3)

# baseline code
%perl -w
$x = (defined $y)? $y :'undef' ."\n";
print $x;
^D
undef    # This is what I expect.

# a minor change
%perl -w
$x = 'a' . (defined $y)? $y :'undef' ."\n";  # now I try to put something up front
print $x;
^D
Use of uninitialized value $x in print at - line 4.  # and I get slapped.

Thanks,
Andy



Confidentiality Notice.
This message may contain information that is confidential or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution,  or copying  of this message, or any attachments, is strictly prohibited.  If you have received this message in error, please advise the sender by reply e-mail, and delete the message and any attachments.  Thank you.



More information about the SanFrancisco-pm mailing list