my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); for my $row ( $row_min .. $row_max ) { my @rowcells = (); # Initialize array at start of new row my $process_flag = 0; # Initialize processing flag to false for my $col ( $col_min .. $col_max ) { my $cell = $worksheet->get_cell( $row, $col ); if ($cell) { push @rowcells, $cell; # Save cell in case we need it if($cell->value eq $pattern) { $process_flag = 1; # We will need this line once it's collected } } else { push @rowcells, ''; # Assuming undef is not a useful option } if ($process_flag) { # Do something with @rowcells, which now contains the whole line } }