First things first...that syntax is badly broken. Printing to Data::Dumper shows that your in-memory structure looks like this:
$VAR1 = 'ARRAY(0x182ae14)'; $VAR2 = undef; $VAR3 = 'ARRAY(0x1b83664)'; $VAR4 = [ 'DES', 'Step2', 'CMD', 'rm file1' ];
So, it sounds like you want to iterate over a hash and issue the commands contained therein. If the keys are known to you, and it appears that they are, there is no need to worry about order. You can simply step through each known key one at a time. What you want is something more like:
my %better_cfg = (); $better_cfg{'DES'}{'Step1'} = "cp file1 file2"; $better_cfg{'DES'}{'Step2'} = "rm file1"; $better_cfg{'DES'}{'Step3'} = "vi file2";
Which results in a data structure that looks like:
$VAR1 = 'DES'; $VAR2 = { 'Step2' => 'rm file1', 'Step1' => 'cp file1 file2', 'Step3' => 'vi file2' };

Now what you have is a hash embeded inside a hash (HoH). The outer hash, %better_cfg, has only one key -- DES. To step through the keys of the inner hash (which should be known to you so that you can maintain order), you'll use the syntax:
my $step1 = $better_cfg{'DES'}{'step1'}; my $step2 = $better_cfg{'DES'}{'step2'}; my $step3 = $better_cfg{'DES'}{'step3'};
If in fact you do not know the value of what will be the inner hash keys (step1, step2, step3), then you don't need to be using a hash at all. Simply read the values from the file into a hash in order, and then iterate over them in that order.

In reply to Re: Reading hash by jrsimmon
in thread Reading hash by Sun751

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.