[EMAIL PROTECTED] wrote:
can i take input to associative array from the user like this:

%words=<stdin>;

well, yeah:


perl -e '%h=<STDIN>;while (($k,$v)=each(%h)){chomp($k,$v);print "$k => $v\n"}'
qw
wq
as
sa
^D
> qw => wq
> as => sa


but that's kinda limiting. Better to take it in steps:

my %hash;
while (chomp(my $key = <STDIN>)) {
  chomp(my $val = <STDIN>);
  $hash{$key} = $val;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to