in reply to Re: How to use Getopt?
in thread How to use Getopt?

Hi, thanks for the script. I really learn alot from it. But there is a minor problem when i run the script.

#Convert to cvs open my $infile_1, "<", $output_1 or die $!; open my $outfile_1, ">", "clock.sum.rpt.csv" or die $!; #$header_1 = "Clock,Sinks,Buffers,Cells,Slew,Path,Vio,Area"; my $lines_1; while(<$infile_1>){ if(/(\w+|\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+.\d+)\s+(\d+.\d+)\s+(\ +d+)\s+(\d+.\d+)/g){ tr/ /,/s; print $outfile_1 "$_"; $lines_1 = $_; }else{ #$lines_1 = $_; #warn "WARN: This line does not follow the normal output pattern, +"; } } #print $outfile_1 $header_1; print $outfile_1 "$lines_1\n";

It shows " Use of uninitialized value $lines_1 in concatenation (.) or string at script_1 line 54, <$infile_1> line 1323." and doesn't allow me to output the csv file. I checked and the line 1323 in my 1st file is a '1'. However this problem does not occur at my 2nd file. Help

Replies are listed 'Best First'.
Re^3: How to use Getopt?
by huck (Prior) on Oct 10, 2017 at 02:12 UTC

    What does $lines_1 get set to if that massive regexp never matchs? Im willing to bet you also found $outfile_1 was empty.

      I found a mistake in my regexp. Now the codes works very well! Thanks so much!!!!