WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Perl: HTML Dateien bearbeiten (http://www.wcm.at/forum/showthread.php?t=138910)

Hussl 11.07.2004 07:11

So, versprochen ist versprochen. Aber da ich von Natur aus so faul bin, hab ich nur ein Skript aus dem Internet kopiert und dieses angepasst.

Quelle Skript: http://www.perl-archiv.de/perl/forum...d_013605.shtml

Code:

#!/usr/bin/perl -w

use strict;

my @dir =  ('D:/Webserver/WebServer-Daten/Chili-it.at/temp/');

my $ext = '.html';
my $nosearch = 'c:/System Volume Information;c:/Recycler;c:/Temp';
my $dir = '';

for $dir (@dir){
        if (opendir(DIR, $dir)) {
                for (readdir(DIR)) {
                        next if (/^\./) || ($nosearch =~ /\Q$_\E/i);
                        push @dir ,"$dir$_/" if (-d "$dir$_");
                        &file($dir,$_) if (-f "$dir$_") && $ext eq  (/.*(\..*)/)[0];
                }
                closedir DIR;
        }
        else {
                print "Fehler in $dir  $!";
        }
}

print "Fertig!\n";

sub file {
        my ($path , $file) = @_;
        print "$path/$file\n";

        open(EIN, "<".$path.$file)      or die "Kann html-Datei nicht oeffnen.\n";
        open(AUS, ">".$path."n_".$file) or die "Kann Ausgabedatei nicht oeffnen.\n";

        while(<EIN> ) {
                chomp($_);
                next if ($_ =~ /\<META name\=generator .+\>/);
                print AUS $_, "\n";
        }
        close(AUS);
        close(EIN);
}

Grüße,
Hussl

K@sperl 14.07.2004 17:29

Falls du Debian GNU/Linux verwendest, gibt's da ein tool dafür:
apt-get install rpl


Code:

rpl (RePLace) - replace strings in multiple files


Alle Zeitangaben in WEZ +2. Es ist jetzt 23:57 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag