#! /usr/local/bin/perl -w use strict; sub forward {$a cmp $b} # removed prototype sub backward {$b cmp $a} # removed prototype my @sorter = qw/forward backward/; my @list = qw(kholsky stencil dnubietna barkhausen manganese fairing fleische flake schlozhauer gascoigne); my $offset = shift || 0; my $subname= $sorter[$offset]; print "$_\n" for sort $subname @list;