my @alist = ( [1 => 'cat'], [3 => 'mouse'], [5 => 'whale'], ); alistinsert(\@alist, 2, 'porcupine'); my $pair = alistatleast(\@alist, 4); # $pair now contains [5, 'whale'] print "The first element of the alist with a key of at least 4 is ($$pair[0], $$pair[1])\n"; sub alistatleast { my ($alist, $minval) = @_; for (@$alist) { return $_ if $$_[0] >= $minval; } } sub alistinsert { my ($alist, $car, $cdr) = @_; my $posn = 0; for (@$alist) { ++$posn if $$_[0] < $car } splice @$alist, $posn, 0, [$car, $cdr]; } #### $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/