About
Pricing
Community
Teams
Start Free Trial
Log in
Europa MacDonald
asked on
11/30/2013
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
Perl
5
1
Last Comment
ozo
8/22/2022 - Mon
ozo
11/30/2013
perl -ape 'open STDOUT,">>$F[0]"' file
Europa MacDonald
11/30/2013
ASKER
sorry, should have asked for it in a .pl file format
ozo
11/30/2013
#!/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;
}
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Europa MacDonald
12/4/2013
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
ASKER CERTIFIED SOLUTION
ozo
12/4/2013
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.