Help for this page

Select Code to Download


  1. or download this
    while(<>){                # <>: used handle is STDIN
       print if $.==5;        # so $. is that handle's line number
    }
    
  2. or download this
    my $file="/etc/hosts";
    my $i=0; # let's use 1-based numbers
    ...
       $i++;
       print "$i: $_" if $i == 5;
    }