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

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

Thread Previous
Unknown Sender
March 4, 2000 10:26
"$x=~0" ... ahem ... oh yes :-/
Message ID:
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

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   |  |  ICQ: 20193661
The quote was selected randomly. Really.    |
Conceit in weakest bodies strongest works.
                                        -- Shakespeare

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