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.
精彩评论