Re: [Boston.pm] catenation of undef with string, 2 cases
"Morse, Richard E.,MGH" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.perl-mongers.boston |
|---|---|
| Message-ID | <[email protected]> |
> On Nov 9, 2016, at 12:49 PM, Mike Small <[email protected]> wrote: > > > #!/usr/pkg/bin/perl > use warnings; > > my $a; > $a .= '70'; > my $b; > $b = 42 . $b; > print "$a, $b\n"; > > > With the script above I get an uninitialized value warning from perl > 5.24 for the second concatenation but not the first. Is there a story > behind this? Something to do with the first case being something you'd > likely want to do without whinging from the interpreter? Interestingly, if you swap the order of the second concatenation, you don’t get the warning, which makes it consistent. I don’t know if this is the reason, but here’s a place this would be somewhat useful: ... my $out; foreach my $k (sort keys %h) { $out .= “$k: $h{$k}\n”; } ... otherwise, you have to start with: my $out = ‘’; (admittedly, that’s how I always start this, but it’s interesting to note that I could leave out the assignment to ‘’.) Ricky The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm