in reply to For loop abortions

If you're a beginner (and even if you're not), it's almost always a good idea to  usewarnings; and  usestrict; in all your scripts. Take a look at the warnings (not errors) below and try to fix them, then come back for more enlightenment.

c:\@Work\Perl\monks\Sellerzzz>type text line 1 second line line the third c:\@Work\Perl\monks\Sellerzzz>perl -e "use warnings; use strict; ;; my @sig; ;; print \"Enter file name: \n\"; my $file = <STDIN>; chomp $file; ;; open (INPUT, $file) || die(\"Could not find $file\"); while (my $line = <INPUT>) { push @sig, <INPUT>, $_; for (my $i; ($i<=scalar @sig); $i++){ for (my $j=($i+1); ($j<=scalar@sig); $j++){ print \"@sig[$j]\n\"; } } close; } " Scalar value @sig[$j] better written as $sig[$j] at -e line 1. Enter file name: text Use of uninitialized value $i in numeric le (<=) at -e line 1, <INPUT> + line 3. Use of uninitialized value $i in addition (+) at -e line 1, <INPUT> li +ne 3. line the third Use of uninitialized value $sig[2] in join or string at -e line 1, <IN +PUT> line 3. Use of uninitialized value in join or string at -e line 1, <INPUT> lin +e 3. Use of uninitialized value $sig[2] in join or string at -e line 1, <IN +PUT> line 3. Use of uninitialized value in join or string at -e line 1, <INPUT> lin +e 3. Use of uninitialized value in join or string at -e line 1, <INPUT> lin +e 3.
I have taken out the use of Text::CSV_XS in the example code since it adds nothing to the point I want to make. BTW: congratulations on the use of a nice Short, Self Contained, Correct (Compilable), Example; pursue the problems it highlights and you will be well on your way to wisdom.


Give a man a fish:  <%-{-{-{-<