[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] aCertainName.pm



Larry Rosler said...
>
>> From: Etienne Grossmann [mailto:etienne@isr.isr.ist.utl.pt]
>
>I don't know what the quotes are for.  And more to the point, why a
>return value of true/false is appropriate.
>
>  sub abs{(my$x=$_[0])=~s/^-//;$x}
>
>There.  That's bad enough, but at least it should work right.

Wouldn't this be better?

sub abs {
	return 0 unless @_;
	 return ($_[0] >= 0)?$_[0]:-$_[0];
}

And it even runs faster too.

-- 
Tim Allwine
IX Development Laboratories
(707)-543-8030 Ext.15

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe