Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Perl module error

by Vaclav_ (Novice)
on Oct 04, 2013 at 14:49 UTC ( #1056888=perlquestion: print w/replies, xml ) Need Help??
Vaclav_ has asked for the wisdom of the Perl Monks concerning the following question:

Can you help me why does this code give the following error: "Missing right curly or square bracket at Gate88/Bot/Core/ line 1, at end of line syntax error at Gate88/Bot/Core/ line 1, at EOF"
package Gate88::Bot::Core::KeyManager; use strict; use warnings; sub new { my $class = shift; my $gs = shift; my $nm = shift; my $self = bless({ 'gs' => $gs, 'nm' => $nm, }, $class); return $self; } 1;
If I remove the method new, perl says syntax is Ok.

Replies are listed 'Best First'.
Re: Perl module error
by toolic (Bishop) on Oct 04, 2013 at 14:54 UTC
    I do not get any error:
    perl -c syntax OK

    How are you using this? I even call it this way:

    use Gate88::Bot::Core::KeyManager; my $x = Gate88::Bot::Core::KeyManager->new();
      Same like you:
      use Gate88::Bot::Core::KeyManager; $s->{'keyboard'} = Gate88::Bot::Core::KeyManager->new( $s->{'gs'}, $s- +>{'nm'} );
      ($s is another object) If I comment the use... line it says syntax Ok, so it must be in the module.
        Maybe there is some problematic whitespace in your .pm file:
        cat -A

        You should download the code from your post, just like I did, and paste it into a new file.

Re: Perl module error
by boftx (Deacon) on Oct 04, 2013 at 23:36 UTC

    Sometimes you can get a meaningful error message from perltidy that will tell you what line has a missing brace/bracket/paren. I would try that and see if it sheds any light. Using that, and perl -c as you did, should point out any problem areas. (But it is hard to imagine that if it passes perl -c that there is anything wrong in the file itself.)

    On time, cheap, compliant with final specs. Pick two.
      Finally. After running perltidy on the module, it's syntax Ok. Perltidy add/removes whitespaces only, right? What could I have messed up with them, I thought whitespaces doesn't really matter. This is not python :D

        I thought whitespaces doesn't really matter. This is not python :D

        No, whitespace doesn't mostly matter, but maybe you invoked the MACRO precompiler features ( perlrun ) or loaded a source filter via PERL5OPT or something like that, something that inserted an extra stray curly brace or square bracket

        Did you save a copy of the broken one? Did you  use Data::Dumper; use Path::Tiny; dd( path( $file )->slurp_raw ) ;

        I suggested perltidy because it will sometimes complain about missing braces, etc, and give you the line number that was unmatched in a way different than perl -c will in the log file. You are indeed most correct that white space doesn't matter. But that doesn't mean that a silly typo doesn't creep in now and again. :)

        On time, cheap, compliant with final specs. Pick two.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1056888]
Approved by toolic
Front-paged by toolic
[Corion]: Yay. Traditional finance situation averted. Bonds can be quoted in amounts (1_000_000 EUR) or per unit (1 unit). And a traditional error is to trade 2_000_000 piece when you meant to trade 2_000_000 EUR.
[Corion]: (one of my scripts simply catches high amounts and I phone people making that trade, ideally before the payment is due)
[Corion]: The sad thing is that my script sits at the end of the pipeline and can only look at the payments due today or tomorrow basically, while there are many more systems further up in the pipeline
[GotToBTru]: better late than never, I guess
[Corion]: GotToBTru: Sure - there is a long and sad story of many frantic cleanups that led us to implement this notification ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-03-29 11:32 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (347 votes). Check out past polls.