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;
}