Skip Menu |

This queue is for tickets about the Term-Shell CPAN distribution.

Report information
The Basics
Id: 2529
Status: resolved
Priority: 0/
Queue: Term-Shell

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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} : ''; } }
Hi all, since this was reported by a guest anonymously and no comments were received, then I'll close this and comment on it: On Wed May 07 13:03:33 2003, guest wrote: Show quoted text
> 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 ) {
You should not call a hash reference - "$i". You also should call $n in something more maningful. Also iterating over the keys should be done in a consistent way because the order of keys is arbitrary and possibly random. All of this can be done in a subclass or a has-a wrapper. Regards, -- Shlomi Fish Show quoted text
> 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} > : ''; > } > }