in reply to Re: Error with User defined data
in thread Error with User defined data
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Error with User defined data
by roboticus (Chancellor) on Aug 13, 2014 at 12:27 UTC | |
|
Re^3: Error with User defined data
by aitap (Curate) on Aug 13, 2014 at 12:31 UTC |