in reply to Having trouble returning the correct values from my sub
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 ... (?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Having trouble returning the correct values from my sub
by lomSpace (Scribe) on Feb 26, 2009 at 22:08 UTC | |
by almut (Canon) on Feb 26, 2009 at 22:16 UTC | |
by lomSpace (Scribe) on Feb 27, 2009 at 20:00 UTC |