I am trying to parse some information from a SSL cert into some variables and would like each line in its own element. Here is my cert data:

Certificate: Data: Version: 3 (0x2) Serial Number: 3235 (0xca3) Signature Algorithm: md5WithRSAEncryption Issuer: C=US, O=GTE Corporation, CN=GTE CyberTrust Root Validity Not Before: Oct 22 17:02:00 2002 GMT Not After : Oct 22 23:59:00 2003 GMT Subject: C=US, ST=XXXX, L=XXXXX, O=XXXX Inc., OU=Security, CN= +XXXXXXX.com/emailAddress=XXXX@XXXX.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): ...KEY... Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: CA:FALSE X509v3 Key Usage: Key Encipherment X509v3 Certificate Policies: Policy: 1.2.840.113763.1.2.1.4 CPS: http://www.XXXXXX.com/XXX/XXX.html Signature Algorithm: md5WithRSAEncryption ...KEY... subject= /C=US/ST=XXXX/L=XXXXX/O=XXXXX Inc./OU=Security/CN=XXXXX issuer= /C=US/O=GTE Corporation/CN=GTE CyberTrust Root

So anyway, here is what I have:

my $SSL = "/usr/local/bin/sudo /usr/bin/openssl"; local (*FH); open (FH, "$SSL x509 -inform PEM -text -noout -subject -issuer -i +n /tmp/expiredcert.crt 2>/dev/null |") or return; my ($var1, $var2) = 0; while (<FH>) { my @args = split(/[\n\r\l]*/); $var1 = $args[1]; $var2 = $args[2]; } close FH; print " $var1 \n $var2 \n";
=====

Eventually, I want to get the X509v3 Data out of this cert into $varX to put elsewhere.

This was just my starting point to see if this would work. How do I get the split() to split each element on the end of line? This isnt working the way I anticipated, My output is

s s

In reply to Split on a new line by Luken8r

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.