Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:42:50+00:00 2026-05-25T10:42:50+00:00

I have recently started programming in Perl (I’ll skip the long story) but I’ve

  • 0

I have recently started programming in Perl (I’ll skip the long story) but I’ve stumbled upon a few errors that I can’t seem to understand:

syntax error at /usr/sbin/test.pl line 238, near ") {"
syntax error at /usr/sbin/test.pl line 247, near "} else"
syntax error at /usr/sbin/test.pl line 258, near ") {"
syntax error at /usr/sbin/test.pl line 276, near ") {"
syntax error at /usr/sbin/test.pl line 304, near "}"
syntax error at /usr/sbin/test.pl line 308, near "}"
syntax error at /usr/sbin/test.pl line 323, near "}"

it seems to be something to do with the brackets surrounding if and else

I’m experienced in C, C#, Java, PHP, Lua, and others so I’m a bit embaressed to get stuck on syntax errors..

I’ve pasted a sample of code that generates a syntax error:

            if (substr(ToString($buffer),0,4) == 'HELO') {
                $contype = 'smtp';

                send($client,'250 Welcome',0);

            } elsif (substr(ToString($buffer),0,4) == 'EHLO') { 
                $contype = 'esmtp';

                send($client,'250-$hostname Welcome',0);
                send($client,'250 SIZE $msgmaxsize',0);
            }

            do {
                recv($client,$buffer,1024,0);

            } while (ToString($buffer) != 'QUIT') {

                if (substr(ToString($buffer),0,10) == 'MAIL FROM:')
                {
                    $sender = ToString($buffer);
                    $sender =~ m/<(.*?)>/;

                    send($client,'250 OK',0);

                } else {
                    send($client,'503 I was expecting MAIL FROM',0);
                    send($client,'221 Bye',0);
                    break;
                } 

}

unfortunately I can not show the entire program.

Perl version 5.10.1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:42:51+00:00Added an answer on May 25, 2026 at 10:42 am

    Besides the mistake of using == and != (which are number-comparison operators) instead of eq and ne for string comparisons, you are missing a semi-colon after the while’s test. That is, you have

    do { ...; } while (...) { if (...) { ... } else {...}}
    

    Note that Perl, like C, supports both forms

    while (expr) { stuff }
    

    and

    do { stuff } while (expr)
    

    and I’m supposing you meant to use the latter form.

    If the above accounts for the error at line 238, then it’s possible that the error at line 247 might go away when you correct it, if it somehow causes a dangling else; but without compiling the code, I don’t quite see how.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been interested in hardware programming recently, but I have not started yet. I
I have only recently started web programming and I am pretty much amazed that
I have recently started programming for the iOS Platform but now I need some
I have recently started programming in WPF and bumped into the following problem. I
I have recently started programming in PHP. I am building a cart in PHP.
I have recently started working on a very large C++ project that, after completing
I have recently started exploring Maven, but I feel a bit overwhelmed of all
I have recently started learning Perl and one of my latest assignments involves searching
I have recently started .NET programming, and looked at both VB.NET and C#. In
I have only recently started programming significantly, and being completely self-taught, I unfortunately don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.