H
Herr Hardy
Hi,
I have some working code, but I think, there's more than one better
way to solve the task:
I have some given Data that should be sorted first on appearance of
string OPEN (on top) and second after the values of the first
occurence of digits, here e.g. 31 to 40.
How can I 'regex' or 'map' this to sort them in one loop already?
Thanks
Hardy
#!/usr/bin/perl
use warnings;
use strict;
my @digitlist;
my @openlist;
my @clsdlist;
while(<DATA>){
/(\d{1,3})/;
push (@digitlist,$1.$_);
}
@digitlist = sort @digitlist;
for(@digitlist){
if (/OPEN/){
push(@openlist,$_);
}else{
push(@clsdlist,$_);
}
}
for(@openlist){
print;
}
for(@clsdlist){
print;
}
1;
# EOF
__DATA__
SBruhrtal32PER09CLSD
SBsorpe31PER19IN18last
RBruhrII33PER11OPEN
RBruhrI34PER14CLSD
RBharkortI40PER09OPEN
I have some working code, but I think, there's more than one better
way to solve the task:
I have some given Data that should be sorted first on appearance of
string OPEN (on top) and second after the values of the first
occurence of digits, here e.g. 31 to 40.
How can I 'regex' or 'map' this to sort them in one loop already?
Thanks
Hardy
#!/usr/bin/perl
use warnings;
use strict;
my @digitlist;
my @openlist;
my @clsdlist;
while(<DATA>){
/(\d{1,3})/;
push (@digitlist,$1.$_);
}
@digitlist = sort @digitlist;
for(@digitlist){
if (/OPEN/){
push(@openlist,$_);
}else{
push(@clsdlist,$_);
}
}
for(@openlist){
print;
}
for(@clsdlist){
print;
}
1;
# EOF
__DATA__
SBruhrtal32PER09CLSD
SBsorpe31PER19IN18last
RBruhrII33PER11OPEN
RBruhrI34PER14CLSD
RBharkortI40PER09OPEN