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

Re: [Fun With Perl] How to swap $p and $q without $tmp



> On Thu, 10 Jun 1999, Michael G Schwern wrote:
>> On Thu, Jun 10, 1999 at 10:16:45PM -0500, Tushar Samant wrote:
>> >
>> >     $q^=$p^=$q^=$p
>> >
>> > (probably well-known; if not, try it)
>>
>> ($p,$q) = ($q,$p);
>
> That's highly obfuscated. Are you sure you want it in maintainable code?
>

Actaully the second one isn't that obfuscated.  Your obviously swaping the
elements in the lists.

Now the 1st one is fairly complicated.  I would definatly use the second.

It just show's how powerfull Perl actaully is.


--

-Derrik

 firebug@apk.net                              http://come.to/thefire
---------------------------------------------------------------------
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety.       - Benjamin Franklin


==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org