Hash in hashes perl code issue

后端 未结 1 1557
青春惊慌失措
青春惊慌失措 2021-01-24 05:35

I tried to store information from below command using perl code,

dis ql(*) all\'|runmqsc MQ_NAME

Assume the output from this command

1条回答
  •  一生所求
    2021-01-24 05:50

    You have to check if the QName is matched and remember it:

    #!/usr/bin/perl
    
    use warnings;
    use strict;
    
    my %QM;
    my $qm = 'MQ_NAME';
    
    open (CHS_OUT, "result.txt");
    my $QName;
    while () {
            my ($QUEUE, $QName1) = / ( QUEUE ) \( ( [^)]+ ) /x;
    
            if ($QName1) {
                    $QName=$QName1;
            }
            if ( my ($item, $value)
            = / ( CURDEPTH | MAXDEPTH ) \( ( [^)]+ ) /x )
            {
                    $QM{$QName}{$item} = $value;
            }
    }
    
    foreach my $Que (sort keys %QM) {
            foreach my $v (keys %{ $QM{$Que} }) {
                    print "$Que : $v = $QM{$Que}{$v} \n";
            }
    }
    

    OUTPUT:

    SYSTEM.RETAINED.PUB.QUEUE : CURDEPTH = 2
    SYSTEM.RETAINED.PUB.QUEUE : MAXDEPTH = 999999999
    SYSTEM.SELECTION.EVALUATION.QUEUE : CURDEPTH = 0
    SYSTEM.SELECTION.EVALUATION.QUEUE : MAXDEPTH = 999999999
    SYSTEM.SELECTION.VALIDATION.QUEUE : MAXDEPTH = 999999999
    SYSTEM.SELECTION.VALIDATION.QUEUE : CURDEPTH = 0
    

    0 讨论(0)
提交回复
热议问题