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

The warning is telling you that your filename contains a newline. That's because when you do  my $filename =<STDIN>;, it's including the newline that's generated when you press Enter.

So when you see: enter file name

And you do myfile<ENTER>

$filename gets "myfile\n" as its contents. If you chomp() $filename, that will get rid of the newline in the variable, and as such the error. So you could do: chomp( my $filename = <STDIN> )

to fix it.