Switch and function prototypes

Discussion in 'Perl Misc' started by Joe Gottman, Oct 9, 2003.

  1. Joe Gottman

    Joe Gottman Guest

    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
    Joe Gottman, Oct 9, 2003
    #1
    1. Advertising

  2. Joe Gottman

    Anno Siegel Guest

    Joe Gottman <> wrote in comp.lang.perl.misc:
    > 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
    Anno Siegel, Oct 9, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bo Jacobsen
    Replies:
    6
    Views:
    497
    David M. Cook
    Mar 7, 2004
  2. Replies:
    5
    Views:
    1,107
  3. Kristian Virkus
    Replies:
    7
    Views:
    397
    Thad Smith
    Feb 8, 2007
  4. quarkLore

    extern and function prototypes

    quarkLore, Apr 19, 2007, in forum: C Programming
    Replies:
    5
    Views:
    298
  5. Syren Baran

    function prototypes and function addresses

    Syren Baran, Jan 9, 2008, in forum: C Programming
    Replies:
    6
    Views:
    300
Loading...

Share This Page