Here's what I imagine. tell me where I'm wrong.
start with @foo = qw( up3 down4 down2 up1 up8 );
and you want
@up = qw( up "" "" up up ); and
@down = qw( "" down down "" "" );
If that's what you want, then something like this should work:
my ( @up, @down );
foreach my $f ( @foo ) {
$f =~ s/\d*$//;
if ( $f eq "up ) {
push @up, $f;
push @down, "";
} else {
push @up, "";
push @down, "";
}
}