Works but not if you have more or fewer than 2 values in a row. Do you?
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > Wagner-David > Sent: Thursday, January 10, 2002 1:31 PM > To: 'Gordon Brandt'; [EMAIL PROTECTED] > Subject: RE: Regex Help Please! > > > Here is a simplistic approach. May want more edits, but is > a starting place. > > Placing the data for testing under DATA: > > while ( <DATA> ) { > chomp; > next if ( /^\s*$/ ); # bypass blank lines > if ( /^<!--\s(\d+.+)\s\/\s(\d+)\s--> <row><v> (.+) <\/v><v> > (.+) <\/v><\/row>/ ) { > printf "%-s, %-s, %-s, %-s\n", $1, $2, $3, $4; > }else { > printf "No hit on data:\n%-s\n", $_; > } > > } > __DATA__ > <!-- 2002-01-08 09:35:00 Eastern Standard Time / 1010500500 --> > <row><v> NaN </v><v> NaN </v></row> > <!-- 2002-01-08 09:40:00 Eastern Standard Time / 1010500800 --> > <row><v> 6.0000000000e+001 </v><v> 6.9000000000e+001 </v></row> > ^--- Script ends here > Output: > > 2002-01-08 09:35:00 Eastern Standard Time, 1010500500, NaN, NaN > 2002-01-08 09:40:00 Eastern Standard Time, 1010500800, > 6.0000000000e+001, 6.9000000000e+001 > > Wags ;) > > -----Original Message----- > From: Gordon Brandt [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 10, 2002 10:17 > To: [EMAIL PROTECTED] > Subject: Regex Help Please! > > > I am trying to come up with a script to convert this output from > RRDTool DUMP to a format which lends itself to import into Excel > 97. Unfortunately, I am just getting started with Perl and do > not have a clear enough grasp of how to configure this so that it > strips out the unwanted parts and formats > it correctly. I would like to be able to feed a file into this > script, and then receive a comma delimited formatted file as output. > > Can anyone point me in the right direction? I have the O'reilly > camel book, but when I read the section on Regex, I feel like an idiot! :( > > Input file: > |---------------- > > (misc header information I want to delete) > > #This is how the data I want to pull out is formatted > <!-- 2002-01-08 09:35:00 Eastern Standard Time / 1010500500 --> > <row><v> NaN </v><v> NaN </v></row> > <!-- 2002-01-08 09:40:00 Eastern Standard Time / 1010500800 --> > <row><v> 6.0000000000e+001 </v><v> 6.9000000000e+001 </v></row> > > |----------- > > Output wanted is: > 2002-01-08 09:35:00 Eastern Standard Time, 1010500500, NaN, NaN > 2002-01-08 09:40:00 Eastern Standard Time, 1010500800, > 6.0000000000e+001, 6.9000000000e+001 > > |------------------ > > Thanks in advance. > > Gordon > -- > > _______________________________________________ > 1 cent a minute calls anywhere in the U.S.! > > http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&u rl=http://www.getpennytalk.com _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users