On 28-feb-04, at 20:32, R. Joseph Newton wrote:
Bjorn Van Blanckenberg wrote:
let say that the file contains these items (every item is seperated with a tab)
...
one title3 state3 name3 pre number3 dip title6 state6 name6 pre2 number6
So what changes have you made in the code to reflect this diffeence in specification. Let us know how *your* adaptations work.
Joseph
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
#!/usr/bin/perl
use strict; use Getopt::Long;
GetOptions(\my %opt, 'filepath=s');
my $filepath = (%opt->{'filepath'});
my @fields = (); my @sorted = (); my $lastbit = 1; my @bits = ();
open(INFILE,$filepath);
chomp(@fields = <INFILE>);
@sorted = map { $_->[0] } sort { $a->[5] cmp $b->[5] } map { [ $_ , (split /\t/) ] } @fields;
foreach (@sorted){ @bits = split; print "\n" if ($bits[4] ne $lastbit); print "$_\n"; $lastbit=$bits[4]; }
this is what I have know but al it does is sorting according item 5 but want it to look in all the items of column 5 and if it contains item 5
print it in one block and then the next block separated with an return so that
one title state name testing number two title2 state2 name2 final number2 one title3 state3 name3 pre number3 four title4 state4 name4 tesing2 number4 six title5 state5 name5 testing3 number5 dip title6 state6 name6 pre2 number6 fun title7 state7 name7 final2 number7
becomes
one title state name testing number four title4 state4 name4 tesing2 number4 six title5 state5 name5 testing3 number5
two title2 state2 name2 final number2 fun title7 state7 name7 final2 number7
one title3 state3 name3 pre number3 dip title6 state6 name6 pre2 number6 -- Oooo. oooO ( ) ( ) ) / \ ( (_/ \_)
Thanks Bjorn Van Blanckenberg
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>