Great Deals said:
what is the difference here?
What is the difference _where_?
(please put the code in the body of your message too)
Subject: open (F, "$fname") vs open $F, $fname;
There are at least 3 differences, so I don't know which difference
is the one that you are asking about...
1) the 1st one has a useless use of double quotes,
the 2nd one doesn't.
2) the 1st one has parens around open's argument list,
the 2nd one doesn't.
3) The 1st one has a filehandle as the first argument,
the 2nd one has a scalar as the first argument.
I can add my to open my $F, $fname, but
not open (my F, "$fname").
Looks like you mean difference #3, so let's factor out
the first two differences:
open F, $fname vs open $F, $fname;
Can I use $F the same as F?
Yes and no, depending on what you mean by "use the same".
The best and most general answer is: No
See Abigail's followup regarding how a scalar and a filehandle differ.
OTOH, if you meant "use the same" as in doing input/output,
then the answer is: Yes
<F> # input with a filehandle
<$F> # input with a ref to anon filehandle (see: perldoc -f open)
print F "stuff\n" # output with a filehandle
print $F "stuff\n" # output with a ref to anon filehandle