RE: How to split up a string with carriage returns into an array

2011-11-07 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Paul Rousseau Sent: 04 November 2011 20:38 To: perl Win32-users Subject: RE: How to split up a string with carriage returns into an array ... I forgot to mention I

Re: How to split up a string with carriage returns into an array

2011-11-04 Thread Andy_Bach
I tried @ans = split (/\r/s, $msg); @ans = split (/\r/g, $msg); @ans = split (/\r\n/s, $msg); @ans = split (/\r\n/g, $msg); 2 things - Perl should handle the \r\n part for you - \n is normally a match for whatever your OS's end of line marker is. You also don't need the modifiers on the

RE: How to split up a string with carriage returns into an array

2011-11-04 Thread Tobias Hoellrich
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

Re: How to split up a string with carriage returns into an array

2011-11-04 Thread will trillich
On Fri, Nov 4, 2011 at 1:15 PM, andy_b...@wiwb.uscourts.gov wrote: Perl should handle the \r\n part for you - \n is normally a match for whatever your OS's end of line marker is. But just in case you're on *nix and processing a Windo~1 file, split( /[\r\n]+/, $msg ) is reasonably

RE: How to split up a string with carriage returns into an array

2011-11-04 Thread Barry Brevik
I tried @ans = split (/\r/s, $msg); @ans = split (/\r/g, $msg); @ans = split (/\r\n/s, $msg); @ans = split (/\r\n/g, $msg); I think, if you are using \r and \n, it has to appear in this order \n\r. Also, unless I misunderstand your question, this works for me (on Windows):

RE: How to split up a string with carriage returns into an array

2011-11-04 Thread Paul Rousseau
Well Community, The string that I thought was using carriage return/line feeds actually does not have any in them. (I had copied the message string from within an HTM file, and by pasting it, the lines broke up accordingly. Naturally, that led me to believe there were CR/LFs in the

RE: How to split up a string with carriage returns into an array

2011-11-04 Thread Andy_Bach
Parsing English is hard ;- but if you're fairly confident of the formatting, you can try and add in a marker and then split on that: $msg =~ s/((?:JAN|FEB|...|OCT|NOV|DEC)\s\d+\s\-)/|#|$1/g; @ans = grep { /\w/ } split('\|#\|', $msg); The elipsis there is the rest of the months (note, they