Europa MacDonald
asked on
Separating rows in a list according to value of first column
I have a list of data, I have sorted it into numerical ascending order according to the first column.
I have to now read the master file and separate out into new files all of the rows that start with the same number.
Could you help me please with code to do this ?
thanks
I have to now read the master file and separate out into new files all of the rows that start with the same number.
Could you help me please with code to do this ?
thanks
perl -ape 'open STDOUT,">>$F[0]"' file
ASKER
sorry, should have asked for it in a .pl file format
#!/usr/bin/perl
use strict;
use warnings;
my $f='';
while( <> ){
/(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f or warn "$f $!");
print;
}
use strict;
use warnings;
my $f='';
while( <> ){
/(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f or warn "$f $!");
print;
}
ASKER
I tried
#!/usr/bin/perl
use strict;
use warnings;
my $f='master.vim';
while( <> ){
/(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f or warn "$f $!");
print;
}
thankyou
but it just hangs for a long time
#!/usr/bin/perl
use strict;
use warnings;
my $f='master.vim';
while( <> ){
/(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f or warn "$f $!");
print;
}
thankyou
but it just hangs for a long time
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.