[Melbourne-pm] When is an lvalue an lvalue?
jarich at perltraining.com.au
Mon Feb 20 18:23:38 PST 2012
On 20/02/12 18:24, Tim Connors wrote:
> $md5->add(substr($$dataRef, $seekPosn, 131072));
> Not really an lvalue, is it? I can sort of see why it does that - it
> doesn't know that the value is being passed to a function that isn't then
> going to modify its arguments, but ... counterintuitive. I wonder if
> there's another way substr could have handled the returning of null data
> that pleases legacy programs that don't follow perl best practices.
I don't know about substr, but another way you could fix your code is to handle
the "is my seek position out of bounds" yourself:
$md5->add( length($$dataRef) < $seekPosn ? undef : substr($$dataRef,
$seekPosn, 131072) );
but your solution is easier to read (assuming you're suppressing those errors
More information about the Melbourne-pm