Skip to content

Instantly share code, notes, and snippets.

@junichiro
Created February 4, 2010 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichiro/294369 to your computer and use it in GitHub Desktop.
Save junichiro/294369 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
my $example = [1, '', 3, 4, '', ''];
sub func {
my ($example, $value) = @_;
my $ret;
while (!$ret) {
$value = ($value + 1) % @$example;
$ret = $example->[$value-1];
}
return $ret;
}
for (1..6) {
print func($example, $_),"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment