http://www.perlmonks.org?node_id=287110


in reply to Re: Re: String Manupulation
in thread String Manupulation

Remember, I'm new. Be gentle. I'm simply trying to create a log file that will have the current date and timestamp as the filename. But I can't figure out what is wrong with my code. The only thing I can think of is that the filename I'm trying to use is to long.
#!/usr/local/bin/perl -w use strict; my $localtime = scalar localtime; my $tmp = ".txt"; my $logfile = $localtime.$tmp; $logfile =~ tr/ /-/; open( OUTFILE, ">$logfile" ); print OUTFILE "Hello"; close(OUTFILE);
And this is the error I get when trying to run:
print() on closed filehandle OUTFILE at log.pl line 12.
Any hints?