in reply to do until loop breaks before meeting the condition

...} until ($result eq "END" || "end");

"end" is a non-empty string and thus is the or always true!

you maybe meant

...} until ( $result eq "END" or $result eq "end" );

or even better

...} until ( uc($result) eq "END" );

(see uc or lc for details)

Cheers Rolf

(addicted to the Perl Programming Language)

PS: next time please try using <readmore> tags for long code! :)

Replies are listed 'Best First'.
Re^2: do until loop breaks before meeting the condition
by thanos1983 (Parson) on Jun 08, 2014 at 14:38 UTC

    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!
      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!