I have the following code:
#!C:/perl/bin/perl.exe use strict; use warnings; my @tmp_oid = (); while(<DATA>) { chomp; my $last_oid = $_; if ($#tmp_oid < 2) { push @tmp_oid, $last_oid; } else { my $first_oid = shift @tmp_oid; if ( (pack("C*", split('\.', $first_oid)) cmp pack("C*", split +('\.', $last_oid)) ) > 0 ) { print "Sort needed\n"; } push @tmp_oid, $last_oid; } } __DATA__ 1.3.6.1.2.1.7.5.1.1.0.0.0.0.1020 1.3.6.1.2.1.7.5.1.1.0.0.0.0.1021 1.3.6.1.2.1.7.5.1.1.0.0.0.0.1022 1.3.6.1.2.1.7.5.1.1.0.0.0.0.1023 1.3.6.1.2.1.7.5.1.1.0.0.0.0.701
That produces this error:
Character in 'C' format wrapped in pack at sort.pl line 16, <DATA> lin +e 4. Character in 'C' format wrapped in pack at sort.pl line 16, <DATA> lin +e 4. Character in 'C' format wrapped in pack at sort.pl line 16, <DATA> lin +e 5. Character in 'C' format wrapped in pack at sort.pl line 16, <DATA> lin +e 5. Sort needed
My method seems to work correctly determining that a sort is required but why am I seeing this error? If I shorten the OIDs I don't see the error ???

2006-01-18 Retitled by g0n, as per Monastery guidelines
Original title: 'Sorting Question'


In reply to pack() format error. by Anonymous Monk

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.