O.K, here's the code, what I am looking for is to be able to associated qid to from,to field of messages with deffered status.
#!/usr/bin/perl use Data::Dumper; open (Q,"-|" , "cat mailqout" ); my $ref_tomailq= []; my $coutner = 0; my $temp_qid; while(<Q>) { # Ignore the banners and totals next if m{ ^ ( -----Q-ID----- | \s* / \S+ / | \s+ Total \s req +uests: | \ S+ \s+ Queue \s+ status ) }ix; # Ignore any completed jobs next if m{ ^ .{10,20} \s \(job \s completed\) }x; if( m{ ^\w+ }ix ) { my @ar_line = split(/\s+/,$_); my $num_char = length($ar_line[0]); if ( $num_char > "0") { print "$ar_line[$counter] $ar_line[-1]"; $ref_tomailq->[$counter]->{$ar_line[0]}->{"fro +m"} = $ar_line[-1]; $temp_qid = $ar_line[0]; $counter++; } } else { my @ar_line = split(/\s+/, $_); if ($ar_line[1] =~ /Deffered:/) { next; } elsif ($ar_line[1] =~ /<{1}\w+>?/) { #my @ar_email = split(/\s+/, $_); chomp(@ar_line); print "@ar_line\n"; $ref_tomailq->[$counter-1]->{$temp_qid}->{"to" +} = $ar_line[1] } } } print Dumper($ref_tomailq);
output of dumper:
$VAR1 = [ { 'k4NDsM423484' => { 'to' => '<distribution@abc.com>', 'from' => '<support@abc.com>' } } ];
This is fined if there is only one recipient, but does not work well with multiple recipient. How can I it in this format?:
$VAR1 = [ { 'k4NDsM423484' => { 'to' => {'<distribution@abc.com>','noc +@abc.com' } 'from' => '<support@abc.com>' } } ];
or
$VAR1 = [ { 'k4NDsM423484' => { 'to' => ['<distribution@abc.com>','noc +@abc.com' ] 'from' => '<support@abc.com>' } } ];
Any idea thanks.

In reply to Re^2: hashing out lines from mailq... by perlknight
in thread hashing out lines from mailq... by perlknight

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.