Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Optional-parameters/Perl/optional-parameters-1.pl
Normal file
10
Task/Optional-parameters/Perl/optional-parameters-1.pl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
sub sorttable
|
||||
{my @table = @{shift()};
|
||||
my %opt =
|
||||
(ordering => sub {$_[0] cmp $_[1]}, column => 0, reverse => 0, @_);
|
||||
my $col = $opt{column};
|
||||
my $func = $opt{ordering};
|
||||
my @result = sort
|
||||
{$func->($a->[$col], $b->[$col])}
|
||||
@table;
|
||||
return ($opt{reverse} ? [reverse @result] : \@result);}
|
||||
5
Task/Optional-parameters/Perl/optional-parameters-2.pl
Normal file
5
Task/Optional-parameters/Perl/optional-parameters-2.pl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
my $a = [["a", "b", "c"], ["", "q", "z"], ["zap", "zip", "Zot"]];
|
||||
foreach (@{sorttable $a, column => 1, reverse => 1})
|
||||
{foreach (@$_)
|
||||
{printf "%-5s", $_;}
|
||||
print "\n";}
|
||||
Loading…
Add table
Add a link
Reference in a new issue