[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [perl #59650] File::Copy does not handle file objects sanely



Thanks for the bug report, and the patch.

On Mon, Oct 06, 2008 at 04:19:10AM -0700, rabbit+bugs@rabbit.us (via RT) wrote:

> The _eq() function used to determine if 'from' and 'to' are the same
> has an extremely naive implementation, completely unable to deal
> with smart objects (i.e. Path::Class::File). I propose the following
> version instead:

It doesn't even deal with two IO::Scalar objects, which was the source of the
original bug report that prompted the change that created _eq():

http://rt.perl.org/rt3/Public/Bug/Display.html?id=32135

> use overload ();
> use Scalar::Util ();
> sub _eq {
>     my ($from, $to) = map {
>         ( Scalar::Util::blessed ($_) and overload::Method ($_, q{""}) )
>             ? "$_"
>             : $_
>     } (@_);
>     return '' if ( (ref $from) xor (ref $to) );

Is there any particular reason you chose xor over ne ?
I can't think of any corner case where the two would differ, or one not warn
where the other would.

>     return $from == $to if ref $from;
>     return $from eq $to;
> }

Nicholas Clark


References to:
"rabbit+bugs@rabbit.us (via RT)" <perlbug-followup@perl.org>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]