Hello again.

On friday, I wrote this node asking for help in understanding how the <> operator works in a scalar context, and I gave test code and output that mimiced the problem I was seeing. However, now it seems that the sample code was too simple, so I've reworked the problem.

The orginal code was written to traverse several subdirectories getting one file per directory, parse some information and produce output to a central file. These subdirectories are usually numbered starting with 0 running up to 500 or 1000. The test code that I present below is designed to run in the main directory and get the approprate file in each subdirectory so that it can be opened, parsed, etc.

#!/usr/bin/perl -w use strict; my $EXON_IN; for (my $i=0; $i < 5; $i++){ $EXON_IN = <$i/*test.txt>; print "$i, -$EXON_IN-\n"; }
Some of the comments offered on the previous node on this topic focused on the fact that it was a constant string in the <>, so I have changed the test code to more accuately reflect the real situation. Also, another comment seemed to indicate (though I am honestly not sure I understand) that since this was the "same" fileglob each time through I was getting the alternating behavior shown by the output below. This fileglob is different in two respects though: it has the subdirectory in it ($i), and it has a wild card. It produceds the same sort of output though:
[scott@blast test]$ ./test.pl 0, -0/0_test.txt- Use of uninitialized value in concatenation (.) or string at ./test.pl + line 7. 1, -- 2, -2/2_test.txt- Use of uninitialized value in concatenation (.) or string at ./test.pl + line 7. 3, -- 4, -4/4_test.txt-
Here is the directory structure:
[scott@blast test]$ ls -R .: 0 1 2 3 4 test.pl ./0: 0_test.txt ./1: 1_test.txt ./2: 2_test.txt ./3: 3_test.txt ./4: 4_test.txt
Your continued help and guidence in this matter is greatly appricated.

Scott


In reply to More Fileglob in scalar context question by scain

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.