in reply to Finding the Shortest Element in an Array
Hope that helps. Here is the documentation on what is going on with the Schwartzian Transform.#!/usr/bin/perl -w use strict; my @array = qw(hello superduper hi); #our good friend the ST (aka: Schwartzian Transform) my $shortest = shift @{[ map{$_->[1]} sort{$a->[0] <=> $b->[0]} map{[length $_, $_]}@array ]}; print $shortest;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding the Shortest Element in an Array
by Limbic~Region (Chancellor) on Oct 13, 2005 at 20:14 UTC | |
by jeffa (Bishop) on Oct 13, 2005 at 20:34 UTC | |
by sauoq (Abbot) on Oct 13, 2005 at 22:18 UTC | |
by Perl Mouse (Chaplain) on Oct 14, 2005 at 11:05 UTC | |
by sauoq (Abbot) on Oct 14, 2005 at 15:30 UTC | |
by injunjoel (Priest) on Oct 13, 2005 at 21:06 UTC |