#!/usr/bin/perl # headchge.prl == useful to change things in
of HTML files # # crude perl script to find a piece of text ($from_text) # in files of a certain filename format ($file_glob) # occurring before the marker (case insensitive) # in a specified directory ($start_dir) or any subdirectory below that # program replaces occurrences of that text with a specified replacement # ($to_text) # $case_sens chose case sensitive or insensitive search # $verbose sets level of output # $verbose = 0 gives total count only # $verbose = 1 gives count of lines changed per file # $verbose = 2 says as it processes each file (excessive) # allfiles.prl copyright claimed by Chris Evans (C.Evans@sghms.ac.uk) -- June 1996 # You're welcome to redistribute or use this file as you like provided that you # a) don't make a profit out of it # b) don't remove this copyright declaration # You may change the file for your own use as much as you like, but # if you give that changed version to others please let me know: # a) what you changed and why (I write bad code and am happy to incorporate # improvements with acknowledgements) # b) whether you are keeping acknowledgement to me (I'd like it!!!) # c) whether you plan to make money out of it (highly unlikely I'd say!!!) $start_dir = "."; # where to start find finding files $file_glob = "*.htm"; # target files to process $from_text = "value"; # string to change $to_text = "content"; # what to change it to $case_sens = 0; # 1 for case sensitive, 0 for not $trusting = 0; # 1 if you will allow backup files to be deleted after changes $verbose = 1; # 0 - summary only, 1 tells you which files it's changed, 2 is too much! $bak = ".bak"; # backup extension # now run through all subdirectories looking for files open(FIND, "find $start_dir -name \"$file_glob\" -print |") || die "Couldn't run find: $!\n"; if (!FIND) { print "\n\nNo files matching $file_glob found in or below $start_dir\n\n"}; while ($filename =