PDA

View Full Version : perl doohicky


unruly
05-30-2002, 11:24 AM
#!C:/WINDOWS/PERL.EXE -w

# by Unruly, h4x0r extrodinare!

opendir(UNCONVERTED, "c:\\My Documents\\unconverted") || die "Error: $!";

foreach(readdir UNCONVERTED) {
next if !/\.txt$/i;
open(FILE, "c:\\My Documents\\unconverted\\" . $_) || die "Error: $!";
@file=<FILE>;
foreach(@file) {
$_ = "

" . $_ . "</P>\n";
}
open(OUTFILE, ">c:\\My Documents\\converted\\" . $_) || die "Error: $!";
print OUTFILE @file;
close(OUTFILE);
print $_ . " ... done\n";
}

closedir(UNCONVERTED);
print "fin\n";


adds P tags around newlines (which should technically be paragraphs of some sort.) you can easily modify it for unix use too.

recluse
05-30-2002, 09:30 PM
I quickly add "#unruly" as a comment so I know who to bug about it and then put it in my stuff_to_study_later dir.

unruly
05-31-2002, 11:41 AM
Originally posted by recluse
I quickly add "#unruly" as a comment so I know who to bug about it and then put it in my stuff_to_study_later dir.

done.