Better monks than I,
So, I've got this input file name in
$ARGV[0], and then three-tuples follow that, composed of an output file, and two csv lists of numbers (I call them maps) :
/bin/perl test.pl input out1 0,2,4,6 0,1,2,3 out2 1,3,5,7 0,1,2,3
Okay, so here is a test loop to populate an array of hashes, each hash containing some useful stuff about each three-tuple.
for ($ii=1;$ii<=@ARGV-1;$ii+=3) # three-tuples (outfile, map1, map2)
{
$files[(($ii-1)/3)]{fname}=$ARGV[$ii];
$files[(($ii-1)/3)]{fhandle}= new IO::File ">".$files[(($ii-1)/3)]{f
+name};
$files[(($ii-1)/3)]{map1}=[split /,/,$ARGV[$ii+1]];
print "map1 : [" . join /,/,$files[(($ii-1)/3)]{map1} . "]\n";
print Dumper(@files);
}
Well, the wierd thing is that the second to last print statement prints something like:
map1 : [ARRAY(0x1dc518c)]
$VAR1 = {
'fname' => 'out1',
'map1' => [
'0',
'2',
'4',
'6'
],
'fhandle' => bless( \*Symbol::GEN0, 'IO::File' ),
};
.
.
.
... instead of:
map : [0,2,4,6]
.
.
.
I've tried adding various brackets and parens (admittedly, not the best way to debug) to try to ensure proper context, but to no avail.
Yes, I know that I could simply print
$ARGV[$ii+1] but that really wasn't the point. Ignoring stylistic and readability concerns (those will be woven into
working code, not this cruft) what's wrong with the code?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.