jamaas has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; $counter = 0; use vars qw($counter); open (INPUT, "< data") or die "Couldn't open data file for reading: $!\n"; while(<INPUT>) { my @a = split; # split record into fields $counter++; #increment counter print "Value($counter) = $_\n" for @a; # print out all fields print "\n"; # blank line between "records" } close (INPUT);
janitored by ybiC: Closed unbalanced <code> tag and removed <br> tags from codeblock
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: perl doesn't like variable
by pg (Canon) on Oct 03, 2004 at 15:17 UTC | |
Re: perl doesn't like variable
by Eimi Metamorphoumai (Deacon) on Oct 03, 2004 at 14:11 UTC | |
Re: perl doesn't like variable
by Dietz (Curate) on Oct 03, 2004 at 14:12 UTC | |
Re: perl doesn't like variable
by jbware (Chaplain) on Oct 03, 2004 at 13:47 UTC | |
by davido (Cardinal) on Oct 03, 2004 at 15:05 UTC | |
by jbware (Chaplain) on Oct 03, 2004 at 18:17 UTC | |
by jamaas (Novice) on Oct 03, 2004 at 14:03 UTC | |
Re: perl doesn't like variable
by johnnywang (Priest) on Oct 03, 2004 at 18:50 UTC |