The loop is taking the values for key and value pair from standard input but, its not exiting if a null value is given to it.#!/usr/bin/perl print"Enter the key\n"; my $key = <STDIN>; chomp($key); print"Enter the value for the Key $key\n"; my $value = <STDIN>; chomp($value); my %h = (); while (($key ne "") && ($value ne "")) { $h{$key} = $value; print "Value inserted successfully\n"; print"Enter the key\n"; my $key = <STDIN>; # chomp($key); print"Enter the value for the Key $key\n"; my $value = <STDIN>; # chomp($value); } foreach my $keyy (keys %h) { print "$keyy => $h{$keyy}\n"; }
In reply to Re^2: Error with User defined data
by Anonymous Monk
in thread Error with User defined data
by a.alandkar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |