Referencing Perl

This blog is created to share perl resources all round the world and to explore the same.

Name:
Location: Chennai, TamilNadu, India

A Computer Freak, interested in programming open source

Wednesday, March 30, 2005

Removing List of things from list of things

my @list = qw/1 2 3/;
%temp=();
my @stoplist = qw/1 2/;
@temp{@list} = ();
delete @temp{@stoplist};
print keys %temp;
--prasanna.k

Swapping of two number without any temporary variables

$a =1;
$b =2;
$b ^= $a ^= $b ^= $a;
print "a = $a, b = $b\n";
--prasanna.k

Removing Duplicates from Array


my @array = qw/1 2 3 4 1 2 3 4/;
%temp = ();
map{$temp{$_}++}@array;
for (sort keys %temp) {
print "$_=>$temp{$_}"."\n";
}
--prasanna.k