Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi saintmike,
diotalevi's perfectly right. Look at it this way:
What you're doing amounts to this, step-wise:
But of COURSE $ret is undefined when you first declare it, because you haven't assigned it to anything! A similarly bad thing is going on here:
where you're trying to create a new scalar variable my($ret), but its value depends on a previously defined scalar called $ret (notice that's the same variable name?), or foo() if the the value of the $ret was previously undefined or zero. If you use strict and warnings (as you always should), then you'll get an error with the second one. Try this (essentially equivalent) code:
Without strict and warnings you get:
but with them you get:
Finally, the reason your title is misleading (as diotalevi suggests), is because it's perfectly fine to do either:
and:
which will both yield the expected:
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/ In reply to Re^3: Why are "a ||= b" and "a = a || b" different?
by liverpole
|
|