Another approach (not to confuse you) is to shove a while loop right in the middle...

...something like...

Code:
while ( <FILEHANDLE> ){
  print( "$i: $_\n" );
  $i++;
}