Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Split on a new line

by odrm (Novice)
on Jul 03, 2007 at 15:29 UTC ( [id://624716]=note: print w/replies, xml ) Need Help??


in reply to Split on a new line

Idiomatic perl uses split() when you know what you want to throw away and a regular expression match when you know what you want.

Putting a "zero or more characters from this class" regular expression into split (as in split /\n\r\l*/) effectively splits a string into individual characters - the regex is true between every single character. Your code would get further if you tried split /\n\r\l+/ ....

Using regular expression matches, you could do something like:

#!/usr/bin/perl use strict; use warnings; undef $/; # read whole file at once our $cert = <>; our ($info) = $cert =~ m/X509v3 Basic Constraints:\s+([^\n]+)/; print "Constraints = $info\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found