develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)

Thread Next
Joseph N. Hall
March 31, 2000 11:26
Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)
Message ID:
> Are there other warnings, besides "Use of uninitialized value", that
> specify an operator?  Perhaps a patch to perldiag that explains this issue
> would be preferred?

There are many, but I don't know of a simple way to find them all.  For

Perl_croak(aTHX_ "Can't coerce %s to integer in %s", sv_reftype(sv,0),

Perl_warner(aTHX_ WARN_NUMERIC,
  "Argument \"%s\" isn't numeric in %s", tmpbuf,

Perl_croak(aTHX_ "Can't coerce %s to string in %s", sv_reftype(sv,0),

I don't know that there are many (or any?) that are as inherently
confusing as the issue with concat, though.

The classic example of "bad error message that probably seemed like a
good idea at the time" of course:

/usr/local/bin/perl5.003 -we '"@foo"'
Literal @foo now requires backslash at -e line 1, within string
Execution of -e aborted due to compilation errors.

perl -we '"@foo"'
In string, @foo now must be written as \@foo at -e line 1, near "@foo"
Execution of -e aborted due to compilation errors.

The first message seems quite reasonable to someone who knows the
history of "" but as anyone who read clpm in those days knows,
it totally baffled newbies, who rightfully were unable to draw any
parallels between the behavior of "$undefined_thingy" and 
"@undefined_thingy" or understand what the meaning of "Literal @foo"
was or where the "required" backslash should go.  The current message
doesn't explain the crux of the problem but at least it leaves the
user at the station rather than putting him on the wrong train out of
town -- AND if he reads perldiag he'll get some reasonable clues.

I'm not completely convinced that adding markers to the bytecode
stream to indicate when run-time interpolation is in effect is such
a bad idea.  It might allow finer-grained control over interpolation
(with overload?  or?) as well as more accurate Deparse, both of which
might turn out to be quite valuable.  Just to resolve the problem 
with the warning message, though, it's way too much work.


Joseph N. Hall, 5 Sigma Productions        mailto:" <joseph> "
Author, Effective Perl Programming . . . . .
Perlfaq Prime  . . . . . . . . . . . . . . . . . .

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About