Help for this page

Select Code to Download


  1. or download this
    #/usr/bin/perl -pi.bak
    $count++ if s/^go/\//;
    
    END { print STDERR "There were $count lines starting with 'go' in the 
    +file\n"; }
    
  2. or download this
    open FILE, "< $file" or die "Can't open input file: $!\n";
    open OUT, "> '$file.new'" or die "Can't open output file: $!\n";
    ...
    print STDERR "There were $count lines starting with 'go' in the file\n
    +";
    rename $file, "$file.bak";  # make backup copy
    rename "$file.new", $file;  # overwrite original file