1

現在、以下の行を という名前のファイルに保存していますgoogle.txt。これらの行を分離し、それらの分離された文字列を配列に格納したいと思います。

最初の行のように

@qf_file= q33AgCEv006441  
@date =    Tue Apr  3 16:12
@junk_message = User unknown
@rf_number = ngandotra@nkn.in

the line ends at the @rf_number at last emailadress
   q33AgCEv006441     1038 Tue Apr  3 16:12 <test10-list-bounces@lsmgr.nic.in>
                     (User unknown)
                     <ngandotra@nkn.in>
    q33BDrP9007220    50153 Tue Apr  3 16:43 <karuvoolam-list-bounces@lsmgr.nic.in>
                     (Deferred: 451 4.2.1 mailbox temporarily disabled: paond.tndt)
                      <paond.tndta@nic.in>
    q33BDrPB007220    50153 Tue Apr  3 16:43 <karuvoolam-list-bounces@lsmgr.nic.in>
                     (User unknown)
                     paocorp.tndta@nic.in>
                                             <dtocbe@tn.nic.in>
                                             <dtodgl@nic.in>
    q33BDrPA007220    50153 Tue Apr  3 16:43 <karuvoolam-list-bounces@lsmgr.nic.in>
                     (User unknown)
                     <dtokar@nic.in>
                     <dtocbe@nic.in>
    q2VDWKkY010407  2221878 Sat Mar 31 19:37 <dhc-list-bounces@lsmgr.nic.in>
                     (host map: lookup (now-india.net.in): deferred)
                     <arjunpan@now-india.net.in>
    q2VDWKkR010407  2221878 Sat Mar 31 19:31 <dhc-list-bounces@lsmgr.nic.in>
                     (host map: lookup (aaplawoffices.in): deferred)
                      <amit.bhagat@aaplawoffices.in>
    q2U8qZM7026999   360205 Fri Mar 30 14:38 <dhc-list-bounces@lsmgr.nic.in>
                     (host map: lookup (now-india.net.in): deferred)
                      <arjunpan@now-india.net.in>
                       <amit.bhagat@aaplawoffices.in>
    q2TEWWE4013920  2175270 Thu Mar 29 20:30 <dhc-list-bounces@lsmgr.nic.in>
                     (host map: lookup (now-india.net.in): deferred)
                               <arjunpan@now-india.net.in>
                               <amit.bhagat@aaplawoffices.in>
4

1 に答える 1

1

テストされていないPerl スクリプト:

このスクリプトを呼び出しましょうparser.pl:

$file = shift;
open(IN, "<$file") or die "Cannot open file: $file for reading ($!)\n";
while(<IN>) {
    push(@qf_file, /^\w+/g); 
    push(@date, /(?:Sat|Sun|Mon|Tue|Wed|Thu|Fri)[\w\s:]+/g);
    push(@junk_message, /(?<=\().+(?=\)\s*<)/g);
    push(@rf_number, /(?<=<)[^>]+(?=>\s*$)/g);
}
close(IN);

これは、回線の最後の電子メールがその回線の「rf_number」であると想定しています。メールには文字が含まれているため、印刷するのが難しい場合があることに注意してください@。perl は、存在しないリストを喜んで印刷します :-)

これをコマンドラインで呼び出すには:

parser.pl google.txt

この作業はこちらをご覧ください。

于 2012-05-31T17:13:30.777 に答える