Jaffer Shaik said:
>Dear Friends,
>
>I want to swap 2 variables without using a tempoarary variable.
>
>I know the below logic
>       a=a+b
>       b=a-b
>       a=a-b
>
>Other than this logic, is thery any other way in perl.
Hey Jaffer,

Yep, this is easy in perl

#!/usr/bin/perl -w
#tested code on 23 July 2004
use strict;
my $first = "a";
my $second = "b";
print "\$first is $first, \$second is $second\n about to swap\n";
($first, $second)=($second, $first);
print "\$first is $first, \$second is $second\n";
-- 
Kind regards,
Hal Ashburner

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to