[oclug] ...and speaking of awk...
Dan Cardamore
wombat at hld.ca
Thu Feb 22 17:35:52 EST 2001
Remember, more than one way :)
I'm a C programmer more than perl, to me this is like C without the
headaches.
Dan
On Thu, Feb 22, 2001 at 04:42:07PM -0500, Kirrily Robert wrote:
> On Thu, Feb 22, 2001 at 03:09:18PM -0500, Dan Cardamore wrote:
> > This is untested, but you can tweak it to get it to work:
> >
> > #!/usr/bin/perl -w
> > use strict;
> >
> > opendir (DIR, '.');
> > my @html = readdir(DIR);
> > closedir(DIR);
> >
> > foreach my $file (@html) {
> > open (FILE, "+<$file") or die "DOH!";
> > my @contents = <FILE>;
> > chomp @contents;
> > seek(F,0,0); # go the beginning of the file
> >
> > # now do your s///g;
> > foreach my $line (@contents) {
> > $line =~ s/http:\/\/some.url/\./g;
> > print FILE "$line\n";
> > }
> > close(FILE);
> > }
> > print "This may be longer than a shell script, but Its done anyways :)\n";
>
> Jesus H. Christ!
>
> perl -pi.bak -e 's{http://some\.url/}{./}' *.html
>
> That'll do the replacements and leave .bak files for you.
>
> K.
>
>
> --
> Kirrily "Skud" Robert
> skud at e-smith.com (work)
> skud at infotrope.net (home)
> _______________________________________________
> oclug mailing list
> oclug at lists.oclug.on.ca
> http://www.oclug.on.ca/mailman/listinfo/oclug
________________________________________________________________
Dan Cardamore wombat at hld.ca http://www.hld.ca
GnuPGP Key: mailto:wombat at hld.ca?subject=sendpgpkey
Email Stats: http://www.hld.ca/~wombat/emailStats
Opensource projects: http://www.hld.ca/opensource
My Groupware project: http://www.gwpeople.com
________________________________________________________________
More information about the OCLUG
mailing list