in reply to problem with naming the file with current date and time

You need to do chomp $filename after reading it from STDIN and before doing anything else with it

/J\

Edit by castaway - reparented from problem with naming the file with current date and time, a dupe