in reply to Re: Of foreach loops and counting
in thread Of foreach loops and counting
In that case, you can use $. (perldoc perlvar) to know what line you are in. For example:
#!/usr/bin/perl while (<DATA>) { print $. . ": $_"; } __DATA__ a b c d e f g h i # Would display when run... $ ./test.pl 1: a 2: b 3: c 4: d 5: e 6: f 7: g 8: h 9: i
Cheers,
KM
|
|---|