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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.