RE: parse help

2007-07-09 Thread Bob McConnell
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 08, 2007 10:49 PM > To: beginners@perl.org > Subject: Re: parse help > > > > > > No, the Input Record Separator ($/) can only hold one string. > > Howev

Re: parse help

2007-07-08 Thread [EMAIL PROTECTED]
> > No, the Input Record Separator ($/) can only hold one string. > However, your records are actually separated by "\n\n", so setting $/ > to "\n\n" and then chomp'ing the record will give you .. No, it does n't work for me. I noticed there are some empty lines in the 'comments' field. Let's say

Re: parse help

2007-07-07 Thread Chas Owens
On 7/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: snip Is there anyway to define in perl that the line starts host= is the record beginning and env= is the record end?? snip No, the Input Record Separator ($/) can only hold one string. However, your records are actually separated by "\n\

Re: parse help

2007-07-07 Thread [EMAIL PROTECTED]
Thanks again. After processing more records I hit another issue. I thoght single empty line is record separator. But i notice that the comment line includes some empty lines as well. (Please read my original posting for clearer understanding what I am looking at) Is there anyway to define in

Re: parse help

2007-06-29 Thread [EMAIL PROTECTED]
> >http://search.cpan.org/author/DCONWAY/Parse-RecDescent-1.94/lib/Parse... > > Hope this helps! > > . I am still at the beginner level. I am afraid this would help me at this stage. Thanks anyway. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECT

Re: parse help

2007-06-29 Thread Chas Owens
On 6/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I would suggest splitting each record on "\n", looping > over the results checking to see if the first character is a space, > and appending that line to the last field if it is or creating a new > key/value pair if it isn't. thank you.

Re: parse help

2007-06-29 Thread [EMAIL PROTECTED]
> I would suggest splitting each record on "\n", looping > over the results checking to see if the first character is a space, > and appending that line to the last field if it is or creating a new > key/value pair if it isn't. thank you. Would you mind posting sample code that does this trick?

Re: parse help

2007-06-25 Thread Tom Phoenix
On 6/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I have some 1000s of records of the following format It looks like a pretty well-defined format. If you are up to using Parse::RecDescent, it will probably do the job with ease. But it's surely a power tool. http://search.cpan.org/a

Re: parse help

2007-06-25 Thread Chas Owens
On 6/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: snip Let's say my script is script.pl and I pass argument such as - , it gets me the details of its record. Any help is appreciated. I know how to do that if it is a single line record.. Also, i don't know how to deal with history line (f

parse help

2007-06-25 Thread [EMAIL PROTECTED]
I have some 1000s of records of the following format host=host1 network=10.x.x.x ip=10.x.x.x gw=10.x.x.1 history=history1 some comments.. multi line with some indentation at the beginning) loc=loc1 owner=owner1 env=env1 host=host2 network=10.x.x.x ip=10.x.x.1 gw=10.x.x.1 history=history2 s

Re: Parse Help

2006-09-13 Thread Rob Dixon
John W. Krahn wrote: John W. Krahn wrote: $ perl -le' my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2= KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9: 52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3: 48,48,49//p_var5=<12345> KQt=1 HZZ=5: 49,50,51,52,53//p_var6=

Re: Parse Help

2006-09-12 Thread Dr.Ruud
Dr.Ruud schreef: > John W. Krahn: >> my @p_var = map { >> ( my $x = $_ ) =~ s/=?> } $text =~ /(p_var\d+=?<[^>]*)>/g; >> >> print for @p_var; > > my %p = /(p_var\d+)=?<([^>]*)>/g; > for my $k(sort keys %p) {print "$k='$p{$k}'"} More variants: my %p = /(p_var\d+)=?<([^>]*)>/g; prin

Re: Parse Help

2006-09-12 Thread Dr.Ruud
"John W. Krahn" schreef: > my @p_var = map { > ( my $x = $_ ) =~ s/=? } $text =~ /(p_var\d+=?<[^>]*)>/g; > > print for @p_var; my %p = /(p_var\d+)=?<([^>]*)>/g; for my $k(sort keys %p) {print "$k='$p{$k}'"} -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail:

Re: Parse Help

2006-09-12 Thread John W. Krahn
John W. Krahn wrote: > > $ perl -le' > my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2= > KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9: > 52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3: 48,48,49//p_var5=<12345> > KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907> K

Re: Parse Help

2006-09-12 Thread Jeff Westman
Too easy! THANKS JOHN!!! On 9/12/06, John W. Krahn <[EMAIL PROTECTED]> wrote: Jeff Westman wrote: > Hello, Hello, > I have a string that I would like to parse and change the format. I'm not > that good at 'map' and I'm just looking for a quick-and-dirty way of doing > this. I've tried s

RE: Parse Help

2006-09-12 Thread Charles K. Clarkson
Jeff Westman wrote: : I would like it "cleaned up" to look like : : p_var1='SD' : p_var2='QR44' : p_var3='543210987' : p_var4='001' : p_var5='12345' : p_var6='20060907' : p_var7='000WR44' : p_var8='X' : p_var9='' #!/usr/bin/perl use strict; use warnings; my $input = q{ [20060911 14:47:11]p

Re: Parse Help

2006-09-12 Thread John W. Krahn
Jeff Westman wrote: > Hello, Hello, > I have a string that I would like to parse and change the format. I'm not > that good at 'map' and I'm just looking for a quick-and-dirty way of doing > this. I've tried substr and split, but there has to be a simple way to do > this. > > My text string lo

Parse Help

2006-09-12 Thread Jeff Westman
Hello, I have a string that I would like to parse and change the format. I'm not that good at 'map' and I'm just looking for a quick-and-dirty way of doing this. I've tried substr and split, but there has to be a simple way to do this. My text string looks like [20060911 14:47:11]p_var1= KQt=