in reply to printing to file, which is a variable

Additionally, isn't the variable supposed to be a reference? Notice the \ in front of $foo
my $foo = ''; open FILEHANDLE, '+>', \$foo or die $!;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh