Hi,
I want to know how to return the most recent file in a dir.
When a new clients sign up I put them in a new dir and then display the new users name using the print command.
Here is what I have at present:
#-#############################################
# Sub: Welcome Message
# This will give out a welcome message to
# the newest member;
$basepath = '/home/----/---------/'; erased for obvious reasons.....
$newmember = 'nm';
print "Content-type: text/html\n\n";
opendir THEDIR, "$basepath$newmember" || die "Unable to open directory: $!";
@allfiles = readdir THEDIR;
closedir THEDIR;
foreach $file (sort { int($a) <=> int($b) } @allfiles) {
if (-T "$basepath$newmember/$file") {
open THEFILE, "$basepath$newmember/$file";
($alias) = <THEFILE>;
close THEFILE;
chomp($alias);
}
}
print "<img src=\"http://www.auctionenid.com/images/smiley2.gif\"> <font[/url] face=\"verdana,Arial\" color=\"black\" size=\"1\">AuctionEnid welcomes it's newest member<br><b>$alias</b></font>";
#------------------------------------------------------#
What it is doing is not returning the latest file in the dir (nm)
I had a file named Loop_y (entered last week) and one called Ebe01 (today) and it's returning the L_oopy file.
Sorry the explanation is not great I'm new to PERL
many thanks
CEO
I want to know how to return the most recent file in a dir.
When a new clients sign up I put them in a new dir and then display the new users name using the print command.
Here is what I have at present:
Code:
#!/usr/bin/perl #-#############################################
# Sub: Welcome Message
# This will give out a welcome message to
# the newest member;
$basepath = '/home/----/---------/'; erased for obvious reasons.....
$newmember = 'nm';
print "Content-type: text/html\n\n";
opendir THEDIR, "$basepath$newmember" || die "Unable to open directory: $!";
@allfiles = readdir THEDIR;
closedir THEDIR;
foreach $file (sort { int($a) <=> int($b) } @allfiles) {
if (-T "$basepath$newmember/$file") {
open THEFILE, "$basepath$newmember/$file";
($alias) = <THEFILE>;
close THEFILE;
chomp($alias);
}
}
print "<img src=\"http://www.auctionenid.com/images/smiley2.gif\"> <font[/url] face=\"verdana,Arial\" color=\"black\" size=\"1\">AuctionEnid welcomes it's newest member<br><b>$alias</b></font>";
#------------------------------------------------------#
What it is doing is not returning the latest file in the dir (nm)
I had a file named Loop_y (entered last week) and one called Ebe01 (today) and it's returning the L_oopy file.
Sorry the explanation is not great I'm new to PERL
many thanks
CEO