#!/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
In reply to perl doesn't like variable by jamaas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |