in reply to Re: do until loop breaks before meeting the condition
in thread do until loop breaks before meeting the condition

Dear Rolf,

You are right about the condition, I was not aware that I could not bind together two conditions like this.

Unfortunately the problem still exists, after the first user input, if the text us under the MAXBYTES = 25 (for example purposes) the loop locks and stays infinitely in. Even with the END or end text input still it is in the loop.

Sorry about the long code, I will read about <readmore>.

Seeking for Perl wisdom...on the process...not there...yet!

Replies are listed 'Best First'.
Re^3: do until loop breaks before meeting the condition
by choroba (Cardinal) on Jun 08, 2014 at 14:52 UTC
    Works for me. It keeps asking until I enter "end" or "END" (or "eNd" etc.).
    #!/usr/bin/perl use warnings; use strict; use constant MAXBYTES => 5; $| = 1; MSG: print "Please be aware maximum length ${\MAXBYTES} characters!:\n +"; my $result; do { print "Send this text to clients:\n\n"; chomp ($result = <STDIN>); if (length($result) >= MAXBYTES) { print "\nYou have reached the limit of characters ", length $result, "!\n\n"; goto MSG } } until uc $result eq "END";
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      To: choroba,

      Thank you for your time and effort.

      It works fine as long as the user enters more than 5 characters, if the user enters less than 5 still the loop breaks. I can not understand this part why it breaks?

      Update

      After carefully observing my mistake, I found out that I was still applying until ($result eq "END" || "end");.

      Your example was absolutely fine, my mistake.

      Again thank you for your time and effort

      Seeking for Perl wisdom...on the process...not there...yet!
        The loop doesn't break for me for short inputs. Are you sure you copied and pasted exactly the code I posted?
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ