Hi, I'm trying to print to multiple file handles and I have found several examples
However, when I tried to pass file handle to it, instead of file name, it fails to print. Here's several code that I tried which produces error
my $f1 = "fileName1"; my $f2 = "fileName2"; open my $fh_email, ">", $f2; #Print stuff to $fh_email open($fh, "| tee -a $f1 $fh_email") or die "Teeing off: $!\n"; #Several other variations I have tried #open($fh, "| tee -a $f1 \*$fh_email") or die "Teeing off: $!\n"; #open($fh, "| tee -a $f1 \\*$fh_email") or die "Teeing off: $!\n"; #open($fh, "| tee -a $f1 \\*\$fh_email") or die "Teeing off: $!\n"; #open($fh, "| tee -a $f1 \*\$fh_email") or die "Teeing off: $!\n"; #Wh +ich was a big mistake as I appended bunch of stuff into lots of file +(which of course I simply did svn revert *) #Print stuff into both files close $fh; #Then continue printing to $fh_email
Error message I see are something like this:
sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `tee -a fileName1 \*GLOB(0x2c06b18)'
Maybe I just have to use for loop to print to both file handles.... Easy way out, but I still would like to know where I've got it wrong :(
Thanks for help!!
In reply to Passing file handle to tee that goes into open by pjkang7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |