/ Published in: Perl
Put this in a script called "update.pl" and call it with "ls *ext|xargs perl update.pl" Be sure to back up the work directory before playing with this, as it is very easy to wipe out the content of a bunch of files at once in this way.
Expand |
Embed | Plain Text
#! /usr/bin/perl -w use strict; $^I=".bk"; while (<>) { print $_; } #run it like this: ls *html|xargs perl update.pl #Here are some other versions of the same kind of thing: #First version: #code snippet to search-and-replace a group of files... $^I=".bk"; # Create a backup while (<>) { s/'/'/gi; print $_ ; } #Second variation: read from a list of files #Assumes that name of list_file is first command line argument #Also assumes we are reading a file with one URL on each line while (<>) { if ($url ne "") { grabit($_, $tag_type, $local_directory, $extensions); } } #Third variation: read a whole file into an array my @whole_file=<WHOLEFILE_HANDLE>; foreach my $i (@whole_file) { print "$i"; }
You need to login to post a comment.
