Implementing Swap [was Re: [Israel.pm] Report on Yesterday's Meeting]

Shlomi Fish shlomif at iglu.org.il
Sun Jun 5 10:04:50 PDT 2005


In the meeting, Shlomo used a swap($a, $b) function. Some people claimed it 
could not be implemented in Perl, or only by using prototypes. But in fact it 
can:

<<<<<<<<<<<
#!/usr/bin/perl

use strict;
use warnings;

sub swap
{
    my ($v1, $v2) = (@_);
    $_[0] = $v2;
    $_[1] = $v1;    
}

my $i = 500;
my $j = 32;
swap($i,$j);

print "\$i=$i ; \$j=$j\n";

my $array = [0,1,2,3,4,5];
swap($array->[1],$array->[3]);
print '$array = ' . join(", ", @$array) . "\n";
>>>>>>>>>>>

Try it!

Another thing that MiGo claimed was that Internet Explorer did not support 
accesskey="". However, it can do just that. For example at the page:

http://www.shlomifish.org/

If you press Alt+N and then enter, you'll be redirected to the next page.

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

Tcl is LISP on drugs. Using strings instead of S-expressions for closures
is Evil with one of those gigantic E's you can find at the beginning of 
paragraphs.



More information about the Perl mailing list