Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: syntax error near else and }

by InfiniteSilence (Curate)
on Feb 04, 2012 at 23:57 UTC ( #951881=note: print w/replies, xml ) Need Help??

in reply to syntax error near else and }


  • You are using warnings but not strict. Add use strict to your code and watch what happens.
  • Lots and lots of nested if statements and the subsequent need to indent is normally a sign that you should strongly consider using subroutines and even a switch statement in your code.
  • I hate it when people post code with line numbers.
  • "Q" or "q" really won't make the input from STDIN quit...the CR does -- try:  perl -e 'print qq|Enter q or Q to quit|; ($list = <STDIN>);'
  • On the same subject, you could have done:   perl -e 'print qq|Give me 20 #s now dammit! |; ($list = <STDIN>); my @stuff = split q| |, $list; print scalar @stuff;'
    where you could have died if there were < 20 numbers entered: die 'not enough numbers!' unless (@stuff == 20);
  • This isn't very readable and you should be using eq instead: ...$work == ' ') . How many spaces is that -- 2 or 3? Since I cannot tell immediately I don't know. Try,  perl -e 'my $work = q~     ~; if ($work eq q| | x 5){print 1};'
    or perhaps a regex.
I recommend that you check to see if your code is on par with the other students in your class. If not then you might try and reread whatever material you were given. If it is look ahead in your materials to see if, near the end of the course, you will be expected to write terse, readable, working code. If not, consider leaving the class and getting your money back. Your time and money would be far better invested in a good book. There are recommendations available at

Celebrate Intellectual Diversity

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951881]
[choroba]: Good morning!
[Discipulus]: good morning choroba!
[Corion]: Hi choroba, Discipulus! I hope you had a good weekend
erix looks for a red-herring joke but can't find one
Discipulus has worked physically and he rediscovered he is no more wont..
erix instead casts a baleful eye on another mysql q.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2017-01-23 09:22 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (192 votes). Check out past polls.