pigeonjp has asked for the wisdom of the Perl Monks concerning the following question:

Hi I've searched a large portion of the website without being able to find and answer to this. I've tried numerous attmepts at trying to create a file using a variable with no success. This is my latest attempt $filename = "$timestamp.txt"; open (NEWFILE, ">$filename"); where the variable $timestamp is defined earlier in my code i've also tried directly creating it with no success open (NEWFILE, ">$timestamp.txt"); i need the .txt to be at the ext for the filename any help will be greatly appreciated

Replies are listed 'Best First'.
Re: creating a file using a variable name
by azatoth (Curate) on Jun 25, 2001 at 20:13 UTC
Re: creating a file using a variable name
by bwana147 (Pilgrim) on Jun 25, 2001 at 20:15 UTC

    The syntax seems all right. Try and print an error message, maybe it's something as silly as permissions.

    open(NEWFILE, ">$filename") or die "Error: $!"

    --bwana147

A reply falls below the community's threshold of quality. You may see it by logging in.