One thing that is weird is that you call the routine with a parameter $k
my $komp_dir = get_directory($k);
but you're not using that parameter anywhere in the routine
sub get_directory{ my @dirs = glob("C:\\Documents and Settings\\mydirectory\\Desktop\ +\KOMP\\*"); foreach my $maid_dir(@dirs){ if (-d $maid_dir){ # directory check if ($maid_dir=~m%\d+\s[A-Z]%){ # match the dir name return $maid_dir; } } } }
so it will effectively always return the same $maid_dir, i.e. the first directory from @dirs where your regex matches.
Presumably you intended to use that $k somewhere in get_directory ... (?)
In reply to Re: Having trouble returning the correct values from my sub
by almut
in thread Having trouble returning the correct values from my sub
by lomSpace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |