On 5/16/06, Smith, Derek <[EMAIL PROTECTED]> wrote:
My hash creations are not working as I expected: %hash = ( @mir, @mir2 ); Why?
Probably because that expression isn't a list of key-value pairs. If you're collecting @mir (a list of keys?) and @mir2 (a list of corresponding values?), no wonder you're having troubles. You're hammering with the wrong kind of violin, and you're not even holding it right.
foreach my $lv (@lvs) { push @mir => (grep /mirror/i, `lvdisplay $lv`); push @mir2 => (grep s/^LV Name\s*//, `lvdisplay $lv`);
Don't run the same command twice! Store its output into an array. Then you can process that array to find $some_key and $some_value that goes with it, and store those into your hash (not into arrays) as you go along: $hash{$some_key} = $some_value; And did you really mean to use s/// on $_ within grep()? That's bad form, even if Perl lets you get away with it. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>