so what im trying to do is open up 4 files, whether they exist or not, and put in a scalar string into each. i encounter the error "Can't use string (">poo.txt") as a subroutine ref while "strict refs" in use at ./2.pl line 12. " i have tried to call on to qw() with the FILE1, FILE2, etc etc within and calling the array index to the filename but then i get the same error only instead of >poo.txt its FILE1
#!/usr/bin/perl use strict; my $scalar = "We Be Killing Zombies Tonite"; my @array = (">poo.txt", ">moo.txt", ">doo.txt". ">goo.txt"); open(FILE1, $array[0]) or die "uno problemo"; open(FILE2, $array[1]); open(FILE3, $array[2]); open(FILE4, $array[3]); foreach(@array){ print $array[$_] ("$scalar"); }
im not looking for a blunt answer to just fix the problem and move on with my programming exercises, id like to learn why this doesnt work, so i can better understand how i can fix a problem like this in the future.. thanks for all your help guys!
In reply to Output To File with Array help by SirDonkeyPunch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |