Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Perl script to Create a hash as capitals of any 5 states of india and print the capital if state is entered &

+1 vote
asked Jul 24, 2020 by Atluri Nikhitha (140 points)
edited Jul 25, 2020 by Atluri Nikhitha
Create a hash as capitals of any 5 states of india and print the capital if state is entered & print a state if capital is entered in perl

1 Answer

0 votes
answered Jul 26, 2020 by xDELLx (10,500 points)
%state_capitals= ('AA', 'aa', 'BB','bb','CC','cc','DD','dd','EE','ee');

@states = keys %state_capitals;
@capitals = values %state_capitals;
$size = @states;
%capitals_state= ();

for ($x=0;$x<$size;$x=$x+1){
        #print "$x\n";
        #print "$states[$x] \t  $capitals[$x]\n";
        $capitals_state{@capitals[$x] } = @states[$x];

}

print "$state_capitals{'AA'}\n";
print "$capitals_state{'aa'}\n";
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...