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

Re: unexpected result of stringification.

From:
nick
Date:
March 18, 2001 08:24
Subject:
Re: unexpected result of stringification.
Message ID:
E14efuF-0001pD-00@roam1
<abigail@foad.org> writes:
>On Mon, Mar 12, 2001 at 11:59:24AM +0000, Nick Ing-Simmons wrote:
>> >
>> >Is this a bug or not?
>> 
>> It cannot be - changing either is bound to break something.
>> 
>> >Is there a way to fix this?
>> 
>> Not without breaking scripts which rely on the behaviour.
>
>
>I've a bit of a problem with that reasoning. That would mean you can
>never, ever fix a bug, because there's bound to break something.

It is a way of defining what can be a bug. If the behaviour is useful
and likely to be used it isn't a bug it is a feature.

> > print 'foo'=~/(.*)/ &&  $1,   'bar'=~/(.*)/ && $1,  "\n";
> > print 'foo'=~/(.*)/ && "$1", 'bar'=~/(.*)/ && "$1", "\n";

In this case I assume that there is an existing body
of code that expects $1 to to be the last value matched, so that making a copy
as it is passed to print (or subs in general) would break that code at least.
And the second line shows that there is an easy way to get the copy if that 
is what you want.

-- 
Nick Ing-Simmons




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