Hello everyone. Some of you have been kind enough to work with me in chatter with this, but this is a little much to copy in chatter. I am trying to store the file names in an array, which I was surprisingly able to do, however when I try to get each file from the array and open it I am unable to. My suspicion is that I am using the wrong context, my error message is "Couldn't open file: ARRAY", which is why I think I have a list in a scalar context.

sub getFiles { my @fileNames = [ "manimp1.txt", "manimp2.txt" ]; for my $i (0..$#fileNames) { open (FILE, "<", $fileNames[$i]) or die "Couldnt open file: $ +fileNames[$i]\n"; while (<FILE>) { $count++; my @line_array = split (/\t/, $_); chomp(@line_array); my $key = shift(@line_array); my $aref = [@line_array]; $newPrices{$key} = $aref; } delete ($newPrices{'Part Num.'}); } }

I also tried

for my $file (@fileNames) { open (FILE, "<", $file) or die "Couldnt open file: $file\n";

This produced the same error. What I am attempting to do is build one hash with these two files, which was working fine when I was using user input to get the file names but since the file names will not change I wanted to bypass user input.

Sample of the data is as follows:
Part Num. Description Base Price Code 001051536 * (R/B 455632) 455632 001460 Ring 11.17 003034 Ball 0.82 018422 Nut 1.69 037506 Ring 3.25 041112023071 Seal Kit 402.98 041112030171 Engine Gasket Kit 611.32 041112030271 Seal Kit 1,035.86
I think I got all of the "problems" in here, double tabs, commas in the prices (who even does that), replacement parts, and non replaced parts.

In reply to Opening an array of file names by tnyflmngs

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.