http://www.perlmonks.org?node_id=1042924

walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:

I have directories on my Solaris 10 box like so:
/home/vize/units/11780540/moving_code_AFT /home/vize/units/91540670/moving_code_INT ..etc
Now, each one of those numbers I am referring to as a unit. The moving_code_(THREE CAPITAL LETTERS) directory has three random letters, so I am using glob to figure out what the directory is named. However, I am running into an issue.
#!/usr/bin/perl use strict; use warnings; my $UNIT_DIR = '/home/vize/units'; # Get all units in $UNIT_DIR my $dh; opendir $dh, $UNIT_DIR or die "Couldn't open dir '$UNIT_DIR': $!"; my @units = grep { !/^\.\.?$/ } readdir $dh; closedir $dh; if ( @units ) { foreach my $unit (@units) { my $moving_code_dir = glob("$UNIT_DIR/$unit/moving_code_*"); my $moving_code = (split("/",$moving_code_dir))[-1]; if ( $moving_code_dir ) { print "$unit good\n"; } else { print "$unit bad\n"; } } }
Simple, not much really there. The problem I am having is that this piece of code always finds the moving_code_ directory for every other unit, even though the directory exists for every unit.
00116122 good 00114295 bad 00114952 good 00116121 bad 00117351 good 00114294 bad 00114293 good 00114292 bad 00114291 good 00117349 bad 00116120 good 00116119 bad
Now, I know the moving_code_ directory is there, and it's the same as the previous unit (except the three random letters), so I'm not sure why it's not finding it. Could this be an issue with Solaris 10 filesystem? Am I doing something wrong with my glob here? Any ideas? I am at a loss.