spstansbury has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: filehandle in warning not what I expected...
by Corion (Patriarch) on Dec 27, 2010 at 20:47 UTC | |
|
Re: filehandle in warning not what I expected...
by Anonymous Monk on Dec 27, 2010 at 20:57 UTC | |
|
Re: filehandle in warning not what I expected...
by JavaFan (Canon) on Dec 27, 2010 at 21:31 UTC | |
by spstansbury (Monk) on Dec 27, 2010 at 21:51 UTC | |
by spstansbury (Monk) on Dec 27, 2010 at 21:57 UTC | |
by JavaFan (Canon) on Dec 27, 2010 at 22:34 UTC | |
|
Re: filehandle in warning not what I expected...
by ysth (Canon) on Dec 28, 2010 at 10:40 UTC |