okay, so after a bit of optimiziren™ now it looks like that:
%ECHI = ( [...skipped...] 12 => # CMS R12 and above { length => 493, header => 'CALLID,ACWTIME,ANSHOLDTIME,CONSULTTIME,DISPTIME,DURATIO +N,SEGSTART,SEGSTOP,TALKTIME,NETINTIME,ORIGHOLDTIME,QUEUETIME,RINGTIME +,DISPIVECTOR,DISPSPLIT,FIRSTVECTOR,SPLIT1,SPLIT2,SPLIT3,TKGRP,EQ_LOCI +D,ORIG_LOCID,ANS_LOCID,OBS_LOCID,UUI_LEN,ASSIST,AUDIO,CONFERENCE,DA_Q +UEUED,HOLDABN,MALICIOUS,OBSERVINGCALL,TRANSFERRED,AGT_RELEASED,ACD,DI +SPOSITION,DISPPRIORITY,HELD,SEGMENT,ANSREASON,ORIGREASON,DISPSKLEVEL, +EVENT1,EVENT2,EVENT3,EVENT4,EVENT5,EVENT6,EVENT7,EVENT8,EVENT9,UCID,D +ISPVDN,EQLOC,FIRSTVDN,ORIGLOGIN,ANSLOGIN,LASTOBSERVER,DIALED_NUM,CALL +ING_PTY,LASTDIGITS,LASTCWC,CALLING_II,CWC1,CWC2,CWC3,CWC4,CWC5,VDN2,V +DN3,VDN4,VDN5,VDN6,VDN7,VDN8,VDN9,ASAI_UUI', format => 'V13 v12 x2 C17 A21 A8 A10 A8' . 'A10'x3 . 'A25 A13 A17 +A17 A3' . 'A17'x5 . 'A8'x8 . 'A96', bits => {index => 25, format => '@76b9'}, signed => [14, 16, 17, 18], segment => 38, strstart => 51 } ); [...skipped...] read(INFILE, $buf, 8); ($ver, $seq) = unpack("V2", $buf); die localtime() . " Unsupported file version $ver, can't process" unle +ss grep $ver, keys %ECHI; print localtime() . " Processing file $ARGV[0], version $ver, sequence + $seq"; print OUTFILE $ECHI{$ver}{header} if $PRINT_HEADER; my $processed = 0; while(read(INFILE, $buf, $ECHI{$ver}{length})) { my @data = unpack($ECHI{$ver}{format}, $buf); splice @data, $ECHI{$ver}{bits}{index}, 0, split(//, unpack($ECHI{$ver}{bits}{format}, $buf)); if ($DATE_FORMAT) { for (my $i = 6; $i < 8; $i++) { $data[$i] = strftime($DATE_FORMAT, localtime($data[$i])); } }; foreach my $index (@{$ECHI{$ver}{signed}}) { $data[$index] = unpack('s', pack('S', $data[$index])); }; for (my $i = $ECHI{$ver}{strstart}; $i <= $#data; $i++) { $data[$i] = '"' . $data[$i] . '"'; }; die localtime() . " Cannot write to file: $!" unless print OUTFILE join ',', @data; $processed++; print localtime() . " Processed record $processed, Call ID " . $data[0] . ", Segment " . $data[$ECHI{$ver}{segment}]; };
i don't see here anything left to optimize. any thoughts?

In reply to Re: yet another "reading binary data" question by dwalin
in thread yet another "reading binary data" question by dwalin

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.