开发者

Text based Data Entry

I开发者_Python百科 want a sample text-based data-entry template in Perl (console application) that can run through telnet. E.g:

 Name:___________________  Education:____________________
 College:__________________ Address:____________________

The user has to enter in the relevant fields.


You can take input by reading from the special file handle STDIN. Loop through the fields you want inputted, and store the results in a hash:

my @fields = qw/name education college address/;
my %data;
for my $field ( @fields ) {
    print "$field: ";
    chomp( my $input = <STDIN> );
    $data{$field} = $input;
}
printf "Hello, %s!\n", $data{name};

chomp removes the trailing newlines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜