Sellerzzz has asked for the wisdom of the Perl Monks concerning the following question:
Hello Arbiters of Good Hope,
I am a relative newbie to any kind of coding and just took up using perl after learning the basics in python.
I've not quite got the hang of the 'for' loop syntax; say for example this chunk of code:
use Text::CSV_XS qw(csv); my @sig; print "Enter file name: \n"; my $file = <STDIN>; chomp $file; my $csv = Text::CSV_XS->new({binary => 1}); open (INPUT, $file) || die("Could not find $file"); while (my $line = <INPUT>) ## Pushing values from csv into the array { push @sig, <INPUT>, $_; for (my $i; ($i<=scalar @sig); $i++){ for (my $j=($i+1); ($j<=scalar@sig); $j++){ print "@sig[$j]\n"; } } close; }
Brings me back a compilation error referring to the for loops, as far as I can see they look correct but what the hell do I know. Can anyone help a poor man out of his blind state?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: For loop abortions
by AnomalousMonk (Archbishop) on Mar 18, 2016 at 03:21 UTC | |
|
Re: For loop abortions
by choroba (Cardinal) on Mar 17, 2016 at 22:17 UTC | |
|
Re: For loop abortions
by Laurent_R (Canon) on Mar 17, 2016 at 22:36 UTC | |
by AnomalousMonk (Archbishop) on Mar 18, 2016 at 12:34 UTC | |
by Laurent_R (Canon) on Mar 18, 2016 at 18:34 UTC |