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.

In reply to Coming across an issue with glob. Is only able to find every other directory. by walkingthecow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.