scain has asked for the wisdom of the Perl Monks concerning the following question:
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.
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:#!/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"; }
Here is the directory structure:[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-
Your continued help and guidence in this matter is greatly appricated.[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
Scott
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: More Fileglob in scalar context question
by chipmunk (Parson) on Jul 02, 2001 at 19:44 UTC | |
by scain (Curate) on Jul 02, 2001 at 19:52 UTC | |
|
Re: More Fileglob in scalar context question
by runrig (Abbot) on Jul 02, 2001 at 19:39 UTC | |
|
Re: More Fileglob in scalar context question
by kschwab (Vicar) on Jul 02, 2001 at 20:06 UTC | |
by scain (Curate) on Jul 02, 2001 at 21:05 UTC |