Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: hashing out lines from mailq...

by Fletch (Bishop)
on May 23, 2006 at 20:19 UTC ( [id://551230]=note: print w/replies, xml ) Need Help??


in reply to hashing out lines from mailq...

Yeah, write some perl that pulls out the first item on the first line and the last on the third line and then prints them out.

(Hint: Include more code and you'll get more helpful responses. See also How (Not) To Ask A Question)

Replies are listed 'Best First'.
Re^2: hashing out lines from mailq...
by perlknight (Pilgrim) on May 24, 2006 at 02:39 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://551230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found