#!/usr/bin/perl use strict; use Spreadsheet::XLSX; use SpreadSheet::WriteExcel; my $excel = Spreadsheet::XLSX -> new ('build.xlsx'); my $sheet = $excel->Worksheet('Sheet1'); my ($row_min,$row_max) = $sheet->row_range(); # scan col D and store values my %colD=(); for my $row ($row_min..$row_max){ my $valD = $sheet->{Cells}[$row][3]->{Val}; $colD{$valD} = $row+1; # excel row number } # scan col A starting at row 2 open FILE,'>','feckyou.txt' or die $!; my $workbook1 = Spreadsheet::WriteExcel->new('newproduct.xls'); my $worksheet1 = $workbook1->add_worksheet(); my $write_row = 1; for my $row (1..$row_max){ my $valA = $sheet->{Cells}[$row][0]->{Val}; my $valB = $sheet->{Cells}[$row][1]->{Val}; # does this value exist in Col D if (exists $colD{$valA}) { my $xlrow = $row+1; #this is where it would write to column R print FILE "price change [A$xlrow]=[D$colD{$valA}] Value=$valB\n"; } else { #output new products to text file # ... $worksheet1->write ($write_row, 0, "$valA"); $worksheet1->write ($write_row, 1, "$valB"); $write_row++; # ... } }