rupes0610 has asked for the wisdom of the Perl Monks concerning the following question:
I have some code to select certain strings from a flat file. I am at the point where I can print the file but I would instead like to convert the selected text to CSV form. How is this done?
A line of the tab delimited text looks like this:
[Wed Jun 13 10:20:32 2012 [notice mpmstats: rdy 758 bsy 42 rd 0 wr 29 ka 11 log 0 dns 0 cls 2
Here is my code so far:
#!/usr/bin/perl use strict; use warnings; main (@ARGV); sub main { open(FH, "error_log"); while (my $line = <FH>){ if ($line =~ m/notice/){ if ($line =~ m/rdy/){ print $line; } } } close FH; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Convert Text to CSV
by Anonymous Monk on Jun 19, 2012 at 16:09 UTC | |
|
Re: Convert Text to CSV
by cheekuperl (Monk) on Jun 19, 2012 at 15:00 UTC |