File: while_until.pl

package info (click to toggle)
libio-prompt-perl 0.997004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 228 kB
  • sloc: perl: 846; makefile: 2
file content (23 lines) | stat: -rwxr-xr-x 439 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/perl -w

# The -while and -until flags control whether &prompt returns true on a given
# input...

use IO::Prompt;

while (prompt "first while digit: ", -while => qr/\d/) {
    print "You said '$_'\n";
}

while (prompt "second until digit: ", -until => qr/\d/) {
    print "You said '$_'\n";
}

while (
    prompt "third while digit (not zero): ",
    -while => qr/\d/,
    -until => qr/0/
  )
{
    print "You said '$_'\n";
}