Gotenks
12-04-2000, 04:47 PM
Yes yes, I'm back again with yet another problem I can't figure out =D. Granted, it's probably something sitting right under my nose, but after an hour and a half of looking and not coming up with anything I thought I'd dump it off here for you fellas to take a look at. Ok, whenever I try to run this script I get a "Use of uninitialized value at ./merger.pl line 10." I will bold lines 9-11 for aesthetics.
#!/usr/bin/perl -w
#
# Original code: Scott
# Modifications/Improvements: Brett & YaRness(LNO)
use strict;
# Read in command-line args here.
my $argument = $ARGV[0];
chomp;
if (!$ARGV[0]) {
print "\nFormat: ./merger.pl <client>\n";
exit;
}
my $txtfile = "0";
my $txtfiledata = "0";
#Open up a fresh index and slap a header on it. (Only needed once per issue of course)
open (TITLES, ">index.html") | | die "Can't open index.html ($!)";
open (TITLEHEADER, "${argument}_titleheader.txt") | | die "Can't open ${argument}_titleheader.txt ($!)";
print TITLES <TITLEHEADER>;
close (TITLEHEADER) | | die "Can't close ${argument}_titleheader.txt ($!)";
#Open up the indexdata template along with our header adn footer here.
#No need to have them in the while() if we only need the i/o for close/open once each
open (IDATA, "${argument}_indexdata.txt") | | die "Can't open ${argument}_indexdata.txt ($!)";
open (HEADER, "${argument}_header.txt") | | die "Can't open ${argument}_header.txt ($!)";
open (FOOTER, "${argument}_footer.txt") | | die "Can't open ${argument}_footer.txt ($!)";
#Lets run through the .article files in this directory
while (defined($txtfile = glob("*") ) ) {
if ($txtfile =~ /^.*\.article$/) {
#Open up the .txt article and get her ready
open (TXTFILE, "$txtfile") | | die "Can't open $txtfile ($!)";
my @txtfiledata = <TXTFILE>;
my $newtxtfile = $txtfile;
$newtxtfile =~ tr/A-Za-z0-9//cd;
#Open a new file (using the stripped $newtxtfile), insert the standard header.
open (NEWTXTFILE, ">new_$newtxtfile.html") | | die "Can't open new_$newtxtfile ($!)";
print NEWTXTFILE <HEADER>;
#Lets spit the index listing into the new index.
print TITLES <IDATA>;
#Copy line for line of data from old txt article to new html article.
foreach $txtfiledata (@txtfiledata) {
chomp $txtfiledata;
print NEWTXTFILE "$txtfiledata".'<br>'."\n";
}
#Lets close off this article with a footer
print NEWTXTFILE <FOOTER>;
#Closeing the txt article, and the newly created html article.
close (TXTFILE) | | die "Can't close $txtfile ($!)";
close (NEWTXTFILE) | | die "Can't close new_$newtxtfile ($!)";
}
}
#Lets spit out the footer at the end of the index and wrap up this issue.
open (TITLEFOOTER, "${argument}_titlefooter.txt") | | die "Can't open ${argument}_titlefooter.txt ($!)";
print TITLES <TITLEFOOTER>;
close (TITLEFOOTER) | | die "Can't close ${argument}_titlefooter ($!)";
#Lets close up our global files.
close (TITLES) | | die "Can't close index.html ($!)";
close (HEADER) | | die "Can't close ${argument}_header.txt ($!)\n";
close (FOOTER) | | die "can't close ${argument}_footer.ext ($!)";
close (IDATA) | | die "Can't close ${argument}_indexdata ($!)";
Any help is much appreciated.
[This message has been edited by Gotenks (edited 04 December 2000).]
#!/usr/bin/perl -w
#
# Original code: Scott
# Modifications/Improvements: Brett & YaRness(LNO)
use strict;
# Read in command-line args here.
my $argument = $ARGV[0];
chomp;
if (!$ARGV[0]) {
print "\nFormat: ./merger.pl <client>\n";
exit;
}
my $txtfile = "0";
my $txtfiledata = "0";
#Open up a fresh index and slap a header on it. (Only needed once per issue of course)
open (TITLES, ">index.html") | | die "Can't open index.html ($!)";
open (TITLEHEADER, "${argument}_titleheader.txt") | | die "Can't open ${argument}_titleheader.txt ($!)";
print TITLES <TITLEHEADER>;
close (TITLEHEADER) | | die "Can't close ${argument}_titleheader.txt ($!)";
#Open up the indexdata template along with our header adn footer here.
#No need to have them in the while() if we only need the i/o for close/open once each
open (IDATA, "${argument}_indexdata.txt") | | die "Can't open ${argument}_indexdata.txt ($!)";
open (HEADER, "${argument}_header.txt") | | die "Can't open ${argument}_header.txt ($!)";
open (FOOTER, "${argument}_footer.txt") | | die "Can't open ${argument}_footer.txt ($!)";
#Lets run through the .article files in this directory
while (defined($txtfile = glob("*") ) ) {
if ($txtfile =~ /^.*\.article$/) {
#Open up the .txt article and get her ready
open (TXTFILE, "$txtfile") | | die "Can't open $txtfile ($!)";
my @txtfiledata = <TXTFILE>;
my $newtxtfile = $txtfile;
$newtxtfile =~ tr/A-Za-z0-9//cd;
#Open a new file (using the stripped $newtxtfile), insert the standard header.
open (NEWTXTFILE, ">new_$newtxtfile.html") | | die "Can't open new_$newtxtfile ($!)";
print NEWTXTFILE <HEADER>;
#Lets spit the index listing into the new index.
print TITLES <IDATA>;
#Copy line for line of data from old txt article to new html article.
foreach $txtfiledata (@txtfiledata) {
chomp $txtfiledata;
print NEWTXTFILE "$txtfiledata".'<br>'."\n";
}
#Lets close off this article with a footer
print NEWTXTFILE <FOOTER>;
#Closeing the txt article, and the newly created html article.
close (TXTFILE) | | die "Can't close $txtfile ($!)";
close (NEWTXTFILE) | | die "Can't close new_$newtxtfile ($!)";
}
}
#Lets spit out the footer at the end of the index and wrap up this issue.
open (TITLEFOOTER, "${argument}_titlefooter.txt") | | die "Can't open ${argument}_titlefooter.txt ($!)";
print TITLES <TITLEFOOTER>;
close (TITLEFOOTER) | | die "Can't close ${argument}_titlefooter ($!)";
#Lets close up our global files.
close (TITLES) | | die "Can't close index.html ($!)";
close (HEADER) | | die "Can't close ${argument}_header.txt ($!)\n";
close (FOOTER) | | die "can't close ${argument}_footer.ext ($!)";
close (IDATA) | | die "Can't close ${argument}_indexdata ($!)";
Any help is much appreciated.
[This message has been edited by Gotenks (edited 04 December 2000).]