Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HoH

Posted on 2007-07-23
1
Medium Priority
?
165 Views
Last Modified: 2010-03-05
Work fine with below ::

%HoH = (
        flintstones => {
                lead      => "fred",
                pal       => "barney",

                Mount1 => {
                             'A'  => '1',
                          }
         },


 );

 foreach $family ( keys %HoH ) {
     print "$family: { ";
     for $role ( keys %{ $HoH{$family} } ) {
         if( ref $HoH{$family}{$role} eq 'HASH' ){
         print "$role: { ";
           for $role1 ( keys %{ $HoH{$family}{$role} } ) {
             print "$role1=$HoH{$family}{$role}{$role1} ";
           }
         print "} ";
        }else{
           print "$role=$HoH{$family}{$role} ";
        }

     }
     print "}\n";
 }

=================================
Now add "main" to %HoH to get more information::
%HoH = (
        flintstones => {
                lead      => "fred",
                pal       => "barney",

                Mount1 => {
                             'A'  => '1',
                          }


              main  => "Common",                    # added to %HoH

        },


 );

 foreach $family ( keys %HoH ) {
     print "$family: { ";
     for $role ( keys %{ $HoH{$family} } ) {
         if( ref $HoH{$family}{$role} eq 'HASH' ){
         print "$role: { ";
           for $role1 ( keys %{ $HoH{$family}{$role} } ) {
             print "$role1=$HoH{$family}{$role}{$role1} ";
           }
         print "} ";
        }else{
           print "$role=$HoH{$family}{$role} ";
        }

     }
     print "}\n";
 }

But I am gettting error that :
"Syntax error at Main" .  
Question ::
How to fix foreach for this error ?








0
Comment
Question by:gauravflame
1 Comment
 
LVL 17

Accepted Solution

by:
mjcoyne earned 1000 total points
ID: 19553186
to fix the syntax error, add a comma as below:

%HoH = (
    flintstones => {
        lead   => "fred",
        pal    => "barney",
        Mount1 => {
            'A'   => '1',
            },                           # add a comma here
        main  => "Common",  # added to %HoH
                   }
 );
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question