I am having trouble working with this line of code:
for my $fh (FH1, FH2, FH3) { print $fh "whatever\n" }
I found it on perldoc , but it does not work for me.
The code I have so far is:
my $archive_dir = '/some/cheesy/dir/'; my ($stat_file,$stat_file2) = ($archive_dir."file1.txt",$archive_dir."file2.txt"); my ($fh1,$fh2); for my $fh (fh1, fh2) { print $fh "whatever\n"; }
I get "Bareword" errors in the (fh1, fh2) because I use strict . I also noticed that this example is missing ; , so I suppose there might be a few more errors in this case.
What is the correct syntax for printing two files at once?
file perl printing syntax-error
CheeseConQueso
source share