Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: XLSX retriving if matches

by marinersk (Priest)
on Jun 17, 2017 at 02:52 UTC ( [id://1193002]=note: print w/replies, xml ) Need Help??


in reply to XLSX retriving if matches

An old-school way to do it is to:

  1. Initialize an array at the start of each row;
  2. Initialize a processing flag to false at the start of each row;
  3. Push each cell into that array as it is processed during the inner loop;
  4. Set the processing flag to true when you have your $patternmatch;
  5. At the bottom of the row loop, after processing all the cells in that row, if the flag is set, the array contains the complete row so use it accordingly.

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 fa +lse 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 o +ption } if ($process_flag) { # Do something with @rowcells, which now contains the whole li +ne } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1193002]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-20 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found