perl - call function while reading STDIN -
i use term::readline::gnu, try use event_loop, or event_hook, or callback_read_char attribute without success.
with event_loop, try sample in doc
$term->event_loop(sub { $data = shift; $data->[1] = ae::cv(); $data->[1]->recv(); }, sub { $fh = shift; $data = []; $data->[0] = ae::io($fh, 0, sub { $data->[1]->send() }); $data; });
and have:
cannot `event_loop' in term::readline::gnu
event_hook works not want...it's called during waiting not when char printed.
i don't found how use callback_read_char attribute , if meets needs...
so, how check input (to print digit) , limit input length 10 digits? how can this? or have use module?
this wanted:
#!/usr/bin/perl -w use strict; use warnings; use term::screen::readline; use data::dumper; main(); sub main { $| =1 ; $scr = new term::screen::readline; $scr->clrscr(); $scr->at(1,17)->puts('xxxxxxxxxxxxxxxxxxxxxxxxx'); $scr->at(2,21)->puts('*****************'); $scr->at(4,0)->puts('- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); $scr->at(5,0)->puts(' xxxxxxxxxxxxxxxxxxxxxx: ...................'); $line=$scr->readline( row => 5, col => 26, len => 19, displaylen => 19, line => '', onlyvalid => "[[:digit:]]+", convert => undef, password => undef, overwrite => 1, ); $scr->at(6,0)->puts(' debug => :' . $line); }
Comments
Post a Comment