Hi Experts,
I am relatively new to Perl. I am working on the script below and when I run it, I get these messages:
C:\Tools\Scripts>perl excel2.pl
Use of uninitialized value $titlesrow in print at excel2.pl line 37.
Use of uninitialized value $bugid in concatenation (.) or string at excel2.pl li
ne 38.
Use of uninitialized value $ci in concatenation (.) or string at excel2.pl line
39.
Use of uninitialized value $ip in concatenation (.) or string at excel2.pl line
40.
/n/n/n
C:\Tools\Scripts>
===============================================================================================================
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
Initializing variables
my ($worksheet, $row, $col, $cell, $bugid, $ci, $ip, $titlesrow, $cell1, $cell2);
Manual workbook name and sheet name
my $FILE = “Book1l.xls”;
my $SHEETNAME = “Sheet1”;
the column that contains searchable key
my $KEY_COLUMN = 3;
my $searchstring = $ARGV[0];
my $excel = Spreadsheet::ParseExcel::Workbook->Parse($FILE);
my $sheet = $excel->Worksheet($SHEETNAME);
Sheet limits established
my ( $row_min, $row_max ) = $sheet->row_range();
my ( $col_min, $col_max ) = $sheet->col_range();
In this section, the row that contains the titles is searched, and then the column numbers for the required variables are identified
for my $row ( $row_min … $row_max ) {
for my $col ( $col_min … $col_max ) {
my $cell = $sheet->get_cell( $row, $col );
if ($cell->value()=~/Bug ID/i){$bugid=$col; $titlesrow=$row};
if ($cell->value()=~/Customer Impact/i) {$ci=$col};
if ($cell->value()=~/Impact Probability/i) {$ip=$col};
}
}
Start printing interesting information
$titlesrow++;
for my $row ($titlesrow … $row_max) {
my $cell = $sheet->get_cell( $row, $bugid );
print $cell->value();
my $cell = $sheet->get_cell( $row, $ci );
print $cell->value();
my $cell = $sheet->get_cell( $row, $ip );
print $cell->value();
}