in reply to Is this sort of possible

What you can use is the Schwartzian Transform (thx merlyn). Here is my attempt at your problem.
#!/usr/bin/perl -w use strict; my @FILE = ('123|title|1/1/01','123|btitle|1/1/01','123|atitle|1/1/01' +); print @FILE,"\n"; my @output = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, (split(/\|/,$_))[1]] } @FILE; print @output,"\n";

grep
grep> cd pub grep> more beer

Replies are listed 'Best First'.
Re: Re: Is this sort of possible
by derby (Abbot) on Dec 31, 2001 at 19:23 UTC
    Or why even bother reading the file contents into an array?

    #!/usr/bin/perl -wd open( FILE, "file.dat" ) || die "Cannot Open file ($!)\n"; my @output = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, (split(/\|/,$_))[1]] } <FILE>; close( FILE ); print @output, "\n";

    -derby