How can I get Perl to open/make a .txt file using $input for the file name?

tim85a

New member
I want to get perl to make the file using $input as the name so if 'name' was saved as $input the file would be called 'name.txt' I've got it like this at the mo:

open FILE, ">'$input'.txt" or die $!;

but its not working :( anyone got any ideas?
 
1. Use the three-argument version of open.
2. Use double-quotes to interpolate variables into strings.

open FILE, q{>}, qq{$input.txt} or die $!;
 
Back
Top