No need to use the /s and /g modifiers on the regexp. Try this below.

Cheers - Tobias

$ cat foo.pl
use strict;
use warnings;
my $foo=qq{OCT 31 - Attended CSP weekly meeting. Engaged in third party SCADA 
host (ZedI) problem in Fairview district
NOV 1 - Preparation and attendance of Normandville Phase 1 meetings.
NOV 2 - Maintained project list. Troubleshoot software licensing issues.
NOV 3 - Attended COG facilities meeting. Follow-up of Autosol software licenses.
};
print join("\n***\n", split(/[\n\r]+/,$foo));
$ perl foo.pl
OCT 31 - Attended CSP weekly meeting. Engaged in third party SCADA host (ZedI) 
problem in Fairview district
***
NOV 1 - Preparation and attendance of Normandville Phase 1 meetings.
***
NOV 2 - Maintained project list. Troubleshoot software licensing issues.
***
NOV 3 - Attended COG facilities meeting. Follow-up of Autosol software licenses.
$
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Paul 
Rousseau
Sent: Friday, November 04, 2011 12:08 PM
To: perl Win32-users
Subject: How to split up a string with carriage returns into an array

Hello Perl Community,

   I have string variable, $msg, assigned the following text.

OCT 31 - Attended CSP weekly meeting. Engaged in third party SCADA host (ZedI) 
problem in Fairview district
NOV 1 - Preparation and attendance of Normandville Phase 1 meetings.
NOV 2 - Maintained project list. Troubleshoot software licensing issues.
NOV 3 - Attended COG facilities meeting. Follow-up of Autosol software licenses.


I want to split the string into an array just as it looks. The string does have 
carriage returns in it.

I  tried

@ans = split (/\r/s, $msg);

@ans = split (/\r/g, $msg);

@ans = split (/\r\n/s, $msg);

@ans = split (/\r\n/g, $msg);

and I get no split.

For some reason, the regexp can't find the carriage return and/or line feed.

Now I'm thinking about somehow splitting the string using \w{3}\s\d+\s-\s

Would a look-behind assertion be better?

Perhaps a map function call?

Thank you.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to