I am trying to modify a Perl script to create a different/new log file each time I run the script. I was trying to create each log file by date, but I am having trouble incorporating this concept... This is what I have so far:
#!perl -w
use WWW::Mechanize;
# What URL shall we retrieve?
$url = "http://www.mediabase.com/whatsong/whatsong.asp?var_s=075068071069045070077";
# Create a new instance of WWW::Mechanize
# enabling autocheck checks each request to ensure it was successful,
# producing an error if not.
my $mechanize = WWW::Mechanize->new(autocheck => 1);
# Retrieve the page
$mechanize->get($url);
# Assign the page content to $page
my $page = $mechanize->content;
# Output the page
#print $page;
# Let's also save the page locally
open LOG, ">>", "102.1_content.txt";
#print LOG $page; #######get error here when run from c++....
close(LOG);
########################################
########################################
# INPUT_FILE
open INPUT_FILE, "<", "102.1_content.txt";
########################################
my $html = join '', <INPUT_FILE>;
my @stuff = $html =~ />([^<]+)</g;
########################################
use Time::localtime;
$tm = localtime;
print "*****", $tm->mon+1, "/", $tm->mday, "/",
$tm->year+1900, "--", $tm->hour, "::",
$tm->min, "::", $tm->sec,
"******************************";
##sec, min, hour, mday, mon, year, wday, yday, and isdst
########################################
# OUTPUT_FILE
open OUTPUT_FILE, ">>", ("PLAYLIST_TABLE_"$tm->mon+1, "/", $tm->mday, "/", tm->year+1900".txt") or die $!;
########################################
print OUTPUT_FILE "******************************",
$tm->mon+1, "/", $tm->mday, "/", $tm->year+1900,
"--", $tm->hour, "::", $tm->min, "::", $tm->sec,
"******************************");
print join (" ", @stuff), "\n";
print OUTPUT_FILE join (" ", @stuff), "\n";
print "thats all!\n";
close(INPUT_FILE);
close(OUTPUT_FILE);
I apologize, I know my code is messy, and thanks in advanced...
Nick