in reply to Re^2: restriction in input
in thread restriction in input

You will need to look at Term::Readline or Curses or any of the other "interactive" console things, or you can just implement it yourself using getc.

citromatik reminded me of the module whose name escaped me, Term::ReadKey.

Replies are listed 'Best First'.
Re^4: restriction in input
by citromatik (Curate) on Jan 29, 2009 at 14:56 UTC

    Here is a simple example using Term::ReadKey. The script prompts for a name and reads the input character by character (as they are entered) until a newline is found or the input reaches 15 characters:

    use strict; use warnings; use Term::ReadKey; $!++; print "Enter name: "; my $key; my $name = ""; my $count = 0; ReadMode 4; while ($count < 15){ while (!defined ($key = ReadKey(-1))){ # Waiting for key pressed } last if ($key eq "\n"); print $key; $name .= $key; $count++; } ReadMode 0; # do whatever you want with your input, for example, print it: print "\n$name\n";

    citromatik