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 196781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:47:48+00:00 2026-05-11T16:47:48+00:00

I would expect the block in the second ‘if’ statement to be entered because

  • 0

I would expect the block in the second ‘if’ statement to be entered because of the undef value but the logs show that it isn’t being entered.

sub getcmd{
  my $self = $_[0];
  if ( $self->_recv == OK ){
      push @{$self->{'log'}}, ['NOTICE', "OK"];
      return "My command";          
  }
  push @{$self->{'log'}}, ['ERROR', "Did not get OK back"];
  return undef;
}

...

if (!($ret = $self->getcmd)){
  push @{$self->{'log'}}, ['ERROR', "failed to read after asking for NEXT"];
}
else {
  push @{$self->{'log'}}, ['ERROR', "'undef' not detected in next()"];
}

The log file shows:

[Fri May  8 19:25:56 2009]: ERROR: Did not get OK back
[Fri May  8 19:26:02 2009]: ERROR: 'undef' not detected in next()

Any ideas gratefully accepted.

Edit: Sorry, I’d edited down the code to show the basic flow. I should’ve proofread it a bit better.

  • I added the $ret in getcmd() to simulate what happens in the logging function which just prints out the current value of $ret which is a global variable always used to capture return values.
  • I’d trimmed down the log messages and missed the extra "back"

Thanks for the suggestions and comments. I hadn’t noticed the six second difference in the log timestamps so now I suspect that you’re right about the execution sequence being different to what I originally expected.

I’ll go back and look again. Guess that’s what you get when trying to look at someone else’s "average" Perl after a thirteen hour day trying to get things finished for a "must go live on Monday" project!

I didn’t write the code and simply inherited it. The code was written by a couple of people who think they don’t "need no steenking warnings or stricts".

Imagine 800 lines of Perl and lots of ‘ifs’ but no else statements! No defensive coding at all! 😯

  • 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-11T16:47:48+00:00Added an answer on May 11, 2026 at 4:47 pm

    I think something more complicated is going on here — those log messages seem to be 6 seconds apart, and there’s no way it’d take 6 seconds for the push statement, the return, and the if check.

    Any chance the first log message was from a previous call of the method from some other place in the application?

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

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, it makes quite a bit of sense to use… May 12, 2026 at 12:10 am
  • Editorial Team
    Editorial Team added an answer User control's click event won't fire when another control is… May 12, 2026 at 12:10 am
  • Editorial Team
    Editorial Team added an answer I really doubt it makes any difference at all. May 12, 2026 at 12:10 am

Related Questions

I would expect the block in the second 'if' statement to be entered because
I'm trying to make a quick dummy app so I can learn the ins
I'm writing (in C# with .NET 3.5) an administrative application which will poll multiple
I'm looking to build a server with lots of tiny files delivered by an
I have a thread in which I catch all errors in a big, all-encompassing

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.