##
$file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename
$name = $2;
open(LOCAL, ">$dir/$name") or die $!; #open file
####
( $name ) = ( $file =~ /(\w+(?:\.\w+)?)$/ ); # Note the $ which anchors to the end of string
####
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
####
my ( $sec, $min ) = (localtime( time ) )[0,1];