Subject: | prompt_name_hash( foo => \%foo ) prompts populates %foo |
Hi.
Maybe you wanna add prompt_name_hash to Term::Shell (looks usefull to me)
Example output:
$source{dbpass} []
Accepted dbpass =>
$source{dbhost} []
Accepted dbhost =>
$source{dbuser} [] asdf
Accepted dbuser => asdf
$source{dbname} [1]
Accepted dbname => 1
$VAR1 = {
'dbpass' => undef,
'dbhost' => undef,
'dbuser' => 'asdf',
'dbname' => 1
};
sub prompt_name_hash {
my($self,$n,$i) = @_;
for my $k ( keys %$i ) {
my $ret = $self->prompt('$'.$n."{$k} = ",$i->{$k});
chomp $ret;
$i->{$k} = $ret if length $ret;
printf "\tAccepted %s => %s\n", $k ,length $i->{$k} ? $i->{$k} : '';
}
}
Example output:
$source{dbpass} = asdf
Accepted dbpass => asdf
$source{dbhost} = asddd
Accepted dbhost => asddd
$source{dbuser} = adsff
Accepted dbuser => adsff
$source{dbname} =
Accepted dbname =>
sub prompt_name_hash {
my( $self, $n, $i ) = @_;
for my $k ( keys %$i ) {
my $d = $i->{$k};
$d = '' unless defined $d;
my $ret = $self->prompt('$'.$n."{$k} [$d] ", $d);
chomp $ret;
$i->{$k} = $ret if length $ret;
printf "\tAccepted %s => %s\n",
$k ,
length $i->{$k}
? $i->{$k}
: '';
}
}