Putting in a

print "$data"
statement after your $data assignment quickly shows that you may have the pack statement incorrect. I would expect to see "0" - the hex equivalent of '30' after it's 'pack'd. 30 is an ASN.1 SEQUENCE data type, which would be the start of your ASN.1 prepare method.

$data = pack("H*",$data); print "$data\n";

That 'works' better for me in that the data is now as I'd expect the hex translation to be. Of course, the ASN.1 prepare statement you're using doesn't look correct to me. Your data: 3084 ... starts with 30 (which would be 'PasswordPolicyResponseValue ::= SEQUENCE') but the 84 isn't an ASN.1 type that I know.

UPDATE: Been a while since I worked with this for SNMP decodes - 84 is the length of the SEQUENCE and your $data certainly isn't 0x84 (132) octets long.

Have a look at http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One which explains ASN.1 coding. The example they give translates to your app with the following:

... $asn->prepare(" FooQuestion ::= SEQUENCE { trackingNumber INTEGER, question IA5String } ") or die($asn->error); $data = "3013020105160e416e79626f64792074686572653f"; $data = pack("H*",$data); print "$data\n" ...

That should run successfully as an example for you.

{C} > test 0‼Ç☺♣♦♫Anybody there? $VAR1 = \{ 'question' => 'Anybody there?', 'trackingNumber' => 5 };

In reply to Re: Using Convert::ASN1 to decode an LDAP control by VinsWorldcom
in thread Using Convert::ASN1 to decode an LDAP control by Latro

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.