The keyboard input is captured on STDIN:
#!/usr/bin/perl use warnings; use strict; my $input; print("Your number: "), chomp( $input = <STDIN> ) until $input =~ /^\d+$/; print 3 * $input - 1, $/;
The print, chomp sequence uses the comma operator to make the two part of a single expression for the modifier. The alternative is do { print... ; chomp ...;} until ...;.
After Compline,
Zaxo
In reply to Re: Input/Output through the Keyboard
by Zaxo
in thread Input/Output through the Keyboard
by @rocks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |