it just wouldn't compile

T

tamiry

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.
 
P

Paul Lalli

tamiry said:
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
 
B

Ben Morrow

Quoth "Paul Lalli said:
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
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top