Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
XP is just a number
 
PerlMonks  

Convert Text to CSV

by rupes0610 (Initiate)
on Jun 19, 2012 at 14:53 UTC ( #977089=perlquestion: print w/ replies, xml ) Need Help??
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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://977089]
Front-paged by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2013-05-25 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (521 votes), past polls