Greetings...

I have a script that parses a csv file, looks up some data in another file, and generates a report. Pertinent code is here:

my $report_files_dir = "../Working/New_data"; my $filename_pattern = "Remedy.csv"; $interface_file = "nodes.csv"; open ( my $interface_data, "<", "$report_files_dir/$interface_file" ) +or die $!; opendir ( my $report_files, $report_files_dir) || die "can't opendir $ +report_files_dir: $!"; for ( sort readdir $report_files ) { next unless $_ =~ /$filename_pattern/; open ( my $remedy_file, "<", "$report_files_dir/$_" ) or die $!; while (<$remedy_file>) { chomp; next if ($. == 1); # Parse info from the current line # Use a returned value ($first_node) to look up data in anothe +r file: LOOKUP: while (<$interface_data>) { chomp; my @list = split/\|/; my $ref_id = &clean( $list[2] ); if ( $ref_id =~ /$first_node/ ) { # The CMTS name is in Column 0 $cmts_name = $list[0]; # The CMTS Interface is in Column 1 $cmts_interface = $list[1]; last LOOKUP; } } seek ( $interface_data, 0, 0 ); # Finish doing the report generation... } close ( $remedy_file ); } closedir ( $report_files ); close ( $benchmark_data ); close ( $interface_data ); close ( $progress_file );

But I get the following warnings:

Use of uninitialized value in subtraction (-) at ./load_Remedy.pl line + 503, <$interface_data> line 1894801. Use of uninitialized value in subtraction (-) at ./load_Remedy.pl line + 503, <$interface_data> line 5825736. Use of uninitialized value in subtraction (-) at ./load_Remedy.pl line + 503, <$interface_data> line 6546698.

The issue is not the uninitialized value ( I'm comparing two dates in line 503, and I may indeed be missing a date value in the original data, but the fact the the data file is $remedy_file, not $interface_data, and the line values are nonsensical, none of the files has more that 100K lines. Am I not using seek properly?


In reply to filehandle in warning not what I expected... by spstansbury

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.