it just wouldn't compile

Discussion in 'Perl Misc' started by tamiry, Nov 30, 2006.

  1. tamiry

    tamiry Guest

    Hi,
    I had some code in a module that won't compile. i narrowed down the
    code to the miimu that won't compile. It looks like the division sign
    confuses the switch statement. I'll be happy if someone could point the
    problem(s).
    i also noted that some minor changes make the problem disappear (i
    wrote that at the bottom).

    --------> my file:


    #!/usr/bin/perl -w

    use strict;
    use warnings;
    use Switch;

    sub Function
    {
    my $self = shift;
    my $num = $self->{ratio}/188;

    while(1)
    {
    switch($self->{status})
    {
    case (0)
    {
    print "stt = 0\n";
    }
    }
    }
    }

    sub Junction
    {
    my $self = shift;
    my $num = $self->{ratio}/188;
    }

    ------> end of my file

    "fixes"
    1. remove the entire switch statement.
    2. remove the first division operation
    3. remove the second division operation
    4. add the "#/" (without the quotes) at the end of the line with the
    first division
    (replace
    my $num = $self->{ratio}/188;
    with
    my $num = $self->{ratio}/188;#/
    )

    the error i get is:

    syntax error at C:\Work\Perl\tst.pl line 17, near ")
    {"
    syntax error at C:\Work\Perl\tst.pl line 23, near "}"
    Execution of C:\Work\Perl\tst.pl aborted due to compilation errors.


    please help :)
    thanks.
     
    tamiry, Nov 30, 2006
    #1
    1. Advertising

  2. tamiry

    Paul Lalli Guest

    tamiry wrote:
    > I had some code in a module that won't compile. i narrowed down the
    > code to the miimu that won't compile. It looks like the division sign
    > confuses the switch statement. I'll be happy if someone could point the
    > problem(s).


    Switch.pm is probably the buggiest standard module out there. It uses
    Source Filtering to rearrange your code, and it pretty frequently
    doesn't get it right. I've encountered similar problems to yours in
    the past. I have no advice to offer you other than "get rid of Switch,
    and write the if/elsif's yourself".

    Sorry,
    Paul Lalli
     
    Paul Lalli, Nov 30, 2006
    #2
    1. Advertising

  3. tamiry

    Ben Morrow Guest

    Quoth "Paul Lalli" <>:
    > tamiry wrote:
    > > I had some code in a module that won't compile. i narrowed down the
    > > code to the miimu that won't compile. It looks like the division sign
    > > confuses the switch statement. I'll be happy if someone could point the
    > > problem(s).

    >
    > Switch.pm is probably the buggiest standard module out there. It uses
    > Source Filtering to rearrange your code, and it pretty frequently
    > doesn't get it right. I've encountered similar problems to yours in
    > the past. I have no advice to offer you other than "get rid of Switch,
    > and write the if/elsif's yourself".


    Or perhaps 'wait for 5.10, and use given/when'...

    Ben

    --
    Although few may originate a policy, we are all able to judge it.
    Pericles of Athens, c.430 B.C.
     
    Ben Morrow, Dec 1, 2006
    #3
    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. Thomas Hawtin
    Replies:
    2
    Views:
    395
    Eric Sosman
    May 4, 2006
  2. grocery_stocker
    Replies:
    10
    Views:
    660
    Keith Thompson
    May 25, 2005
  3. Suresh V.

    Wouldn't it be nice if this worked?

    Suresh V., Aug 10, 2008, in forum: Python
    Replies:
    1
    Views:
    210
    Stefan Behnel
    Aug 10, 2008
  4. Casey Hawthorne
    Replies:
    5
    Views:
    425
    Arne Vajhøj
    Apr 25, 2009
  5. Zeng

    datagrid that wouldn't want to sort

    Zeng, Jul 24, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    109
Loading...

Share This Page