Switch and function prototypes

J

Joe Gottman

I tried to compile the following code in my Perl program:

#!/usr/bin/perl

use strict;
use Switch;

sub testSwitch ($)
{
my $param = shift;
switch ($param) {}
}


I got the following error:
syntax error at test.pl line 9, near ") {"
syntax error at test.pl line 10, near "}"
Execution of test.pl aborted due to compilation errors.

Strangely, when I declared the function with no prototype, or replaced the
"$" with "$;", the program compiled fine. Does anyone have any idea why
this is happening?

Joe Gottman
 
A

Anno Siegel

Joe Gottman said:
I tried to compile the following code in my Perl program:

#!/usr/bin/perl

use strict;
use Switch;

sub testSwitch ($)
{
my $param = shift;
switch ($param) {}
}


I got the following error:
syntax error at test.pl line 9, near ") {"
syntax error at test.pl line 10, near "}"
Execution of test.pl aborted due to compilation errors.

Strangely, when I declared the function with no prototype, or replaced the
"$" with "$;", the program compiled fine. Does anyone have any idea why
this is happening?

That looks like a bug in the Switch module to me, though it could also
be a bug in Perl's prototyping system. It's hard to see what's going on,
because Switch.pm uses a source filter. Unless someone else has a better
idea, I'd report it.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top