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
In reply to RE: Re: Of foreach loops and counting
by KM
in thread Of foreach loops and counting
by Cirollo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |