Help for this page

Select Code to Download


  1. or download this
    perl -pi.bak -e '$count++;s/^/$count. /' file_name
    
  2. or download this
    foreach my $line (@file) {
      (undef) = <FILE>; # stores number of lines into $.
    ...
      print FILE, "$count. ";
      if ($count == $.) {last; }
    }
    
  3. or download this
    foreach my $line (@file) {
        $count++;
        print FILE, "$count. $line";
    }
    
  4. or download this
    foreach (@file) {
        $count++;
        s/^/$count. /;
        print FILE;
    }
    
  5. or download this
    (undef) = <FILE>; # stores number of lines into $.
    
  6. or download this
    if ($count == $.) {last; }