By using perl programming, how to print out this hash data using loops and according to the hash data's sequences?
#!/usr/bin/perl
my %restaurant_menu = (
'Menu' => 'Price (RM)',
'Pizza' => 'RM12.00',
'Coca Cola' => 'RM3.00',
'Spaghetti' => 'RM10.00',
'Nugget' => 'RM7.50'
);
i tried this but i cannot get the output.
my @menus = keys %restaurant_menu;
my @prices = values %restaurant_menu;
my $count;
for(count=0;count<6;count++) {
"print "$menus[$count] => $prices[$count]\n";
}
Asking a perl question in a C++ forum may not yield good results.
Maybe your for loop variables need a $
Not to mention that there are only 5 things in your hash, and your loop is 6.