开发者

Text based Data Entry

开发者 https://www.devze.com 2023-02-10 19:32 出处:网络
I开发者_Python百科 want a sample text-based data-entry template in Perl (console application) that can run through telnet. E.g:

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

精彩评论

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