I'm writing some code to search through a series of directories and return the name of the one and only .txt file inside each one. For some reason, though, my variable is only being set correctly every othertime the code runs. It doesn't matter if I search the same directory several times, or different ones. It always fails every other time. Here's a simplified version and its output on my system:
@paths = ( "//johnsp/dist", "//johnsp/dist", "//johnsp/dist", "//johnsp/dist", "//johnsp/dist", "//johnsp/dist" ); foreach $dir (@paths) { my $tmp; print "looking in $dir\n"; $tmp = glob("$dir/*.txt"); print glob("$dir/*.txt"), "\n"; print "set tmp to $tmp\n\n"; } Output: looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to //johnsp/dist/x86.txt looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to //johnsp/dist/x86.txt looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to //johnsp/dist/x86.txt looking in //johnsp/dist //johnsp/dist/x86.txt set tmp to
Any guesses?
---
A fair fight is a sign of poor planning.
In reply to Glob Misbehavin' by Sprad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |