bowei_99 has asked for the wisdom of the Perl Monks concerning the following question:
... and so on. I want the output to look likeUsername: 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)
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
So I thought the following code would be a good start -
while (<IN>) { next if (/^\s*$/); chop; if (/^Username\:\s+([\w\s]+)\s+Owner\:\s+(.*)$/) { $username = $1; $desc = $2; print "$username,$desc,"; } elsif (s/^(Last Login\:\s*)//) { ($login_times{"i"}, $login_times{"ni"}) = split /,/, $ +_; print "$login_times{\"i\"}, $login_times{\"ni\"}\n"; } else { die "line invalid - $_, $!\n"; } } close (IN);
But when I run the code, it doesn't print anything for $username or $desc, even though I know it captures $1 and $2 correctly, as I put in debug statements, showing what they were.
Anybody know what I'm missing here?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Text into CSV
by BrowserUk (Patriarch) on Jan 19, 2006 at 07:39 UTC | |
|
Re: Parsing Text into CSV
by McDarren (Abbot) on Jan 19, 2006 at 07:17 UTC | |
|
Re: Parsing Text into CSV
by radiantmatrix (Parson) on Jan 19, 2006 at 15:37 UTC | |
by bowei_99 (Friar) on Jan 19, 2006 at 19:26 UTC | |
by BrowserUk (Patriarch) on Jan 19, 2006 at 21:38 UTC | |
by bowei_99 (Friar) on Jan 20, 2006 at 05:34 UTC | |
|
Re: Parsing Text into CSV
by arto (Novice) on Jan 20, 2006 at 10:01 UTC |