[oclug] ...and speaking of awk...
Francis Pinteric
linuxdoctor at yahoo.com
Thu Feb 22 15:34:50 EST 2001
Oh, my....
How about this as a filter???
sed -e "s/href=\"http:\//href=\"./g"
Or something like that. I haven't tested it. You might have to fiddle
with the back slashes a bit.
>>>--fja->
--- Dan Cardamore <wombat at hld.ca> 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";
>
> Dan
>
> On Thu, Feb 22, 2001 at 02:45:45PM -0500, Dave Edwards wrote:
> > Hey Gang,
> >
> > I need to alter a directory worth of downloaded html files so
> that the
> > links reference only ./ "this directory." But I can't wrap my
> head
> > around the re necessary to do this. In very loose pseudo, it
> would be:
> >
> > when, in any field, <a href="http://some.url/file.html"> is
> found, replace
> > that with <a href="./same-filename.html">
> >
> > Phew! Any help would be appreciated. Thanks as always,
> >
> > Dave.
> > --
> > PGP Public Key http://www3.sympatico.ca/amoamasam/public-key.txt
> > >Are you now, or have you ever been, a user of the Linux
> operating system?
> > _______________________________________________
> > 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
> ________________________________________________________________
> _______________________________________________
> oclug mailing list
> oclug at lists.oclug.on.ca
> http://www.oclug.on.ca/mailman/listinfo/oclug
=====
There are no stupid questions, but there are a LOT of inquisitive idiots.
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/
More information about the OCLUG
mailing list