in reply to Re^2: Parsing Text into CSV
in thread Parsing Text into CSV

And what output would you want in those cases? The text '(none)' where the date should be?

#! perl -slw use strict; while( <DATA> ) { $_ .= <DATA>; print join',', m[ Username: \s+ (\S+) \s+ Owner: \s+ ([^\n]+ ) \n Last\sLogin: \s+ ( .+ ) \s \( [^,]+, \s+ (.+) \s\( ]x; } __DATA__ Username: JANDERSON Owner: JOE ANDERSON Last Login: 14-JAN-2002 08:14 (interactive), 4-MAR-2002 17:09 (non-in +teractive) Username: PBARRETT Owner: PAUL BARRETT Last Login: 18-JAN-2006 08:14 (interactive), 24-MAR-2005 17:09 (non-i +nteractive) Username: LARRY Owner: LARRY FINE Last Login: (none) (interactive), (none) (non-in +teractive) Username: MOE Owner: HARRY MOSES HOWARD Last Login: 11-JUL-2002 18:08 (interactive), (none) (non-in +teractive) Username: CURLY Owner: JEROME HOWARD Last Login: (none) (interactive), 12-SEP-1997 11:33 (non-in +teractive)

Gives

P:\test>junk JANDERSON,JOE ANDERSON,14-JAN-2002 08:14,4-MAR-2002 17:09 PBARRETT,PAUL BARRETT,18-JAN-2006 08:14,24-MAR-2005 17:09 LARRY,LARRY FINE,(none),(none) MOE,HARRY MOSES HOWARD,11-JUL-2002 18:08,(none) CURLY,JEROME HOWARD,(none),12-SEP-1997 11:33

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Parsing Text into CSV
by bowei_99 (Friar) on Jan 20, 2006 at 05:34 UTC
    Yup, thanks, BrowserUK - that worked great :)