Hi !
If your only need is to get the numerical part, I propose this solution :
#!/usr/bin/perl
use strict;
my $komp_dir ='/Users/mydirectory/Desktop/BioinfDev/SequenceAssemblyPr
+oject/KOMP/';
my @komp_dir_content = glob("$komp_dir/*");
my $k_dir;
foreach $k_dir(@komp_dir_content) {
if (-d $k_dir){
$k_dir =~ s(.*/)();
next if ( $k_dir !~ /^\d+_/);
$k_dir =~ s(_.*)();
print "$k_dir\n";
next;
}
}
I hope it helps !
The problem came from the "use strict" and the loop variable being not declared at main level :
either don't use "use strict" or declare the loop variable (became $k_dir here)
I changed a little variable-names because I think reusing the same name for different usages is an unuseful risk for programs maintenance.
But, of course, you're quite free ...