in reply to Split on a new line

Unless you've done something to $/ which you haven't mentioned, then $_ won't contain newlines inside the while, since the while is already splitting the data up by line.

If you want each line in it's own element in the array, then you are going about it the hard way...

my $SSL = "/usr/local/bin/sudo /usr/bin/openssl"; chomp( my @array = `$SSL x509 -inform PEM -text -noout -subject -issue +r -in /tmp/expiredcert.crt 2>/dev/null` );

Or, if you still want to do it with open...

my $SSL = "/usr/local/bin/sudo /usr/bin/openssl"; local (*FH); open (FH, "$SSL x509 -inform PEM -text -noout -subject -issuer -in /tm +p/expiredcert.crt 2>/dev/null |") or return; my @args = <FH>; close FH;

We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re^2: Split on a new line
by Luken8r (Novice) on Jul 03, 2007 at 18:24 UTC
    This works pretty well. I added a join to get almost what I want.
    my $SSL = "/usr/local/bin/sudo /usr/bin/openssl"; my ($var1, $var2, $var3, $var4, $var5); my $joinvar; chomp( my @array = `$SSL x509 -inform PEM -text -noout -subject -issue +r -in /tmp/expiredcert.crt 2>/dev/null` ); $joinvar = join("\n", @array[25..30]),