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

"$x=~0" ... ahem ... oh yes :-/

Thread Previous
From:
Unknown Sender
Date:
March 4, 2000 10:26
Subject:
"$x=~0" ... ahem ... oh yes :-/
Message ID:
20000304192619.B21686@noris.de
I stumbled on a other rather disturbing problem while checking out my
previous problem:

>> $y=~0
>> p $y 
                      <-- nothing at all!
Ahem... say again?

$ eperl -we '$y=~0; print "$y\n";'
Use of uninitialized value in pattern match (m//) at -e line 1.
Use of uninitialized value in concatenation (.) at -e line 1.

That's rather disturbing for new Perl users.

I definitely don't think that a lone zero should be treated as a pattern,
even if it is behind a '=~'. A '=~ is interpreted as a pattern matching
operator, did you mean " = ~.."?' warning would be in order here, if
possible.

Secondly, "$y\n" isn't a concatenation; it's a string with a variable
inside. I know that internally it's translated to a concatenation, but
the error message either needs to mention both, or the opcodes need to
distinguish the two so that people don't get confused. I'd vote for the
latter solution.

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
Conceit in weakest bodies strongest works.
                                        -- Shakespeare

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About