lundi 24 février 2014

Re: use strict; use warnings; topic




here is some shuffle fun


#!/usr/bin/perl
use strict;
use warnings;


my @array = qw/a b c e r/;

for (my $i=0; $i<scalar @array/2; $i++) {
push @array, shift @array}

for (my $i=$#array; $i>0; $i -= 2) {
my $l1 = pop @array;
my $l2 = pop @array;
unshift @array, $l2;
unshift @array, $l1}

print "@array"





Aucun commentaire:

Enregistrer un commentaire