in reply to Re^2: Recover Excel data from cells with Foreach loop
in thread Recover Excel data from cells with Foreach loop
see foreach loops in perlsyn. Your foreach loop iterates over the list values of 0 to 9 and sets the scalar variable $data to be each element of the list in turn. Because the variable is preceded with the keyword my, then it is lexically scoped, and is therefore visible only within the loop.
Try
poj#!/usr/bin/perl use strict; use Spreadsheet::Read; my $excel = ReadData("TEST.csv"); my $maxrow = $excel->[1]{maxrow}; for my $row (1 .. $maxrow){ my $url = $excel->[1]{'A'.$row}; # do something with url process($url); } sub process { my ($url) = @_; print "Processing $url\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Recover Excel data from cells with Foreach loop
by Perlchaoui (Sexton) on Nov 10, 2018 at 22:33 UTC | |
by 1nickt (Canon) on Nov 10, 2018 at 23:37 UTC | |
by Perlchaoui (Sexton) on Nov 11, 2018 at 18:06 UTC | |
by choroba (Cardinal) on Nov 12, 2018 at 10:22 UTC | |
by hippo (Archbishop) on Nov 12, 2018 at 09:09 UTC |