On 01/23/04 03:36, Bjorn Van Blanckenberg wrote:
the thing i'am looking for is that it is sorted by item 5 and writes back to the file
with an extra line if item 5 is different

A variation on the Swartzian transform: (read from bottom up)


#!/usr/bin/perl

use strict;
use warnings;

print map { $_->[1] . "\n" }
      sort  {$a->[0] cmp $b->[0]}
      map { chomp; [(split /\t/, $_)[4], $_] }
      <DATA>;

__DATA__
one     title   state   name    code1   number
two     title2  state2  name2   code2   number2
one     title3  state3  name3   code3   number3
four    title4  state4  name4   code4   number4
six     title5  state5  name5   code1   number5
dip     title6  state6  name6   code1   number6
fun     title7  state7  name7   code2   number7

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to