in reply to Re^2: curly braces around a lexical file handle
in thread curly braces around a lexical file handle

That's not a realistic example. If you were printing two variables, it would look like

print $name, ", ", age;
or
print "$name, age";

And neither looks similar to the following to me:

print $fh $age;

As for your Perl6 eaxmple, you can do the same in Perl5.

$fh->print($s); # Perl5 $fh.print: $s; # Perl6

Replies are listed 'Best First'.
Re^4: curly braces around a lexical file handle
by moritz (Cardinal) on May 31, 2010 at 16:54 UTC

    That might be true for debugging output, put otherwise usage of print is pretty diverse.

    Ack'ing through my private Perl code I've found pretty many occurrences of print $variable, EXPRESSION and print $variable EXPRESSION where EXPRESSION didn't start with a quote that looked like a separator.

    Perl 6 - links to (nearly) everything that is Perl 6.

      Again, print $variable EXPRESSION is not realistic code.

      I'm saying the real problem is bad naming conventions. You can't argue against that by altering the name of the variables you used. (I'm assuming your didn't actually use "$variable" as the name of your file handle.) What's your actual code?

      Update: Clarified.

        I said I believe this is a problem that's caused by bad naming conventions.

        If you need to rely on proper variable names to recognize a construct as what it is (like you seem to imply), then the syntactic distinctions (here: presence or absence of a comma) between the constructs is too small.

        The reason is that when you debug stuff, you can't rely on the fact that code you read is sane or correct.

        What's your actual code?

        One piece that caught my eye in the grep/ack output was print $response, $/;

        Which (when read inaccurately) could either print to a response file handle, or print a response.

        And don't tell to call that variable $response_fh instead if it's a file handle. For foreign code I have no influence on the naming, and I don't like that for my own code. If I want type annotations, I use a statically typed language which actually checks the type.