in reply to passing parameters to CGI::header
Deparse to the rescue:
BEGIN { $^W = 1; } use CGI (':standard'); use strict 'refs'; my @a; my $i = 0; eval { do { print "\nTake ", $i++, ",\n", header(), "\n"; print "\nTake ", $i++, ",\n", header(@a, "\n"); print "\nTake ", $i++, ",\n", header(@a), "\n"; print "\nTake ", $i++, ",\n", header(), "\n" } }; if ($@) { print "I died: $@\n"; }
On the third and fourth lines, the parens disambiguate the syntax. On the first line, the immediately following comma is taken to mean that you're not passing any parameters. On the third line, there is nothing that tells the compiler that you mean header(@a), "\n" — it looks as though you're saying header(@a, "\n").
The fact that this is happening with &CGI::header is a red herring, btw. Perl always interprets such cases in this fashion. The same would happen regardless of which function you use (except for those with restrictive prototypes).
Makeshifts last the longest.
|
|---|