Re: XML parsing question

2012-03-15 Thread Shlomi Fish
Hi Anirban, On Thu, 15 Mar 2012 20:41:31 +0530 Anirban Adhikary wrote: > I am writting a following code to parse this xml but not able yo understand > that why the value of $bsc_id_1 getting changed. > here is my code > > use strict; > use warnings; > > my $xml_file_to_read = "BSC-19478.xml";

Re: XML parsing question

2012-03-15 Thread Shawn H Corey
On 12-03-15 01:32 PM, Graeme St.Clair wrote: I agree with Lawrence! I am currently using two older packages called XML::SAX and XML::SAX::Expat ; they may well be a bit old-fashioned, but they work for me. I would suggest XML::Twig -- Just my 0.0002 million dollars worth, Shawn Progr

Re: XML parsing question

2012-03-15 Thread Graeme St.Clair
: anirban.adhik...@gmail.com Subject: Re: XML parsing question On 03/15/2012 09:11 AM, Anirban Adhikary wrote: I am writting a following code to parse this xml but not able yo understand that why the value of $bsc_id_1 getting changed. here is my code use strict; use warnings; my

Re: XML parsing question

2012-03-15 Thread Lawrence Statton
On 03/15/2012 09:11 AM, Anirban Adhikary wrote: > I am writting a following code to parse this xml but not able yo understand > that why the value of $bsc_id_1 getting changed. > here is my code > > use strict; > use warnings; > > my $xml_file_to_read = "BSC-19478.xml"; > my $counter = 1; > my $

Re: XML parsing question

2012-03-15 Thread Anirban Adhikary
I am writting a following code to parse this xml but not able yo understand that why the value of $bsc_id_1 getting changed. here is my code use strict; use warnings; my $xml_file_to_read = "BSC-19478.xml"; my $counter = 1; my $bsc_id_1; my $bsc_id; open my $RFH,'<',$xml_file_to_read or die "Can'

Re: XML parsing question

2012-03-15 Thread Shawn H Corey
On 12-03-15 11:01 AM, Anirban Adhikary wrote: I need to create a new xml file from this xml. Now I need to store the first BSC id and need to check it against the other BSC ids. If both ids are same then I need to write the the contents of between the BSC id tag in a new xml file. What have you

XML parsing question

2012-03-15 Thread Anirban Adhikary
Hi List , I have a xml file which looks like 10 1,3,4,7 12,16,21 2,3,3 1,3,6,8 12,17,25 50 AMI_BRANLY_B_1 10 1,3,4,7 12,16,21 2,3,3 1,3,6,8 ON ON 0 I need to create a new xml file from

Re: Parsing Question

2012-02-02 Thread Brandon Phelps
Thanks everyone for the great ideas. After I implemented the solution(s) you guys proposed I stumbled upon Nagios::Object (http://search.cpan.org/~duncs/Nagios-Object-0.21.16/). I did learn a few things from your ideas though so I am grateful none the less! I recommend anyone working with Na

Re: Parsing Question

2012-02-02 Thread Rob Dixon
On 31/01/2012 22:43, Brandon Phelps wrote: Hello all, I am attempting to parse a Nagios status.dat file and am curious about what the most efficient way to do this would be. I'm sure I could come up with something but it would be very convoluted and I'm sure there is a better way. Below is a sam

RE: Parsing Question

2012-02-02 Thread Kronheim, David (Contr)
February 01, 2012 2:11 PM To: jbiskofski Cc: Brandon Phelps; beginners@perl.org Subject: Re: Parsing Question Hi jbiskofski, This script will not work WHY? -- Scalar found where operator expected at . [ Please Check ] line 72, near "$we_are_inside_hoststatus_block" .. This commun

Re: Parsing Question

2012-02-01 Thread jbiskofski
ah - i get it now. thanks. On Wed, Feb 1, 2012 at 3:05 PM, Jim Gibson wrote: > On 2/1/12 Wed Feb 1, 2012 11:24 AM, "jbiskofski" > scribbled: > > > Your comment about the open statement is OK. I guess it really comes down > > to style. I was trying to write something clear that Brandon could

Re: Parsing Question

2012-02-01 Thread Jim Gibson
On 2/1/12 Wed Feb 1, 2012 11:24 AM, "jbiskofski" scribbled: > Your comment about the open statement is OK. I guess it really comes down > to style. I was trying to write something clear that Brandon could improve > upon. It is not simply a matter of style. Because of operator precedence, the s

Re: Parsing Question

2012-02-01 Thread jbiskofski
Timothy Could it be that when you copy pasted the script the line wrap got messed up? It works fine for me. Im using perl 5.12.3 Your comment about the open statement is OK. I guess it really comes down to style. I was trying to write something clear that Brandon could improve upon. Here is a p

Re: Parsing Question

2012-02-01 Thread timothy adigun
Hi jbiskofski, This script will not work WHY? -- Scalar found where operator expected at . [ Please Check ] line 72, near "$we_are_inside_hoststatus_block" .. On Wed, Feb 1, 2012 at 6:38 PM, jbiskofski wrote: > Hey Brandon > > Here is a solution to this problem. It is purposely r

Re: Parsing Question

2012-02-01 Thread jbiskofski
Hey Brandon Here is a solution to this problem. It is purposely really long. It takes the simplest most understandable solution. If you have questions about it let me know. #!/usr/local/bin/perl # always a good idea, forces scope to if/for/foreach/while blocks use strict; # open the file, int

Re: Parsing Question

2012-02-01 Thread Igor Dovgiy
Just my $0.02... can't help offering a slight rewrite of David's great program. Now it's runnable on 5.010 and earlier, and should give out some warnings if hoststatus sections are somehow corrupt: $|++; # comment it out if you don't need to buffer the output my $section_started; my ($host, $state

RE: Parsing Question

2012-02-01 Thread Kronheim, David (Contr)
Brandon, I took most of your comments and sample data and put it in the following program. Taking the data out of the program and parsing it from files and directories, might be a good exercise for you. Generally variables are best declared close to where they are first used. Since the scope of

Re: Parsing Question

2012-01-31 Thread Brandon Phelps
Thanks a ton David, This will definitely help! Not able to try it now but I'll give it a shot first thing tomorrow. -Brandon On 1/31/2012 8:15 PM, Kronheim, David (Contr) wrote: Brandon, I took most of your comments and sample data and put it in the following program. Taking the data out

Parsing Question

2012-01-31 Thread Brandon Phelps
Hello all, I am attempting to parse a Nagios status.dat file and am curious about what the most efficient way to do this would be. I'm sure I could come up with something but it would be very convoluted and I'm sure there is a better way. Below is a sample of the file. The sections I am in

Re: Yet another parsing question

2006-12-15 Thread Eugene Kosov
D. Bolliger wrote: Gallagher, Tim F (NE) am Donnerstag, 14. Dezember 2006 15:29: Lets say that I have a list of data that have a few things in common, ie this is a 1 test to see 2 what is happening 3 to the state of the 4 country all work 1 and no 2 play makes 3 jack a dull boy 4 how 1 much woo

Re: Yet another parsing question

2006-12-14 Thread D. Bolliger
Gallagher, Tim F (NE) am Donnerstag, 14. Dezember 2006 15:29: > Lets say that I have a list of data that have a few things in common, ie > > this is a 1 test to see 2 what is happening 3 to the state of the 4 > country > all work 1 and no 2 play makes 3 jack a dull boy 4 > how 1 much wood 2 could a

Yet another parsing question

2006-12-14 Thread Gallagher, Tim F \(NE\)
Lets say that I have a list of data that have a few things in common, ie this is a 1 test to see 2 what is happening 3 to the state of the 4 country all work 1 and no 2 play makes 3 jack a dull boy 4 how 1 much wood 2 could a wood 3 chuck 4 chuck so I want to grab all data between 1 - 2 and 3 -

Re: File Parsing Question

2006-01-22 Thread Shawn Corey
William Black wrote: Hello, I'm trying to figure out how to read multiple lines from a file at once for parsing. For example,, If the file contained the following: input file Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 I want to read in lines 1-4 for processing then d

re: File Parsing Question

2006-01-22 Thread William Black
Hello, I'm trying to figure out how to read multiple lines from a file at once for parsing. For example,, If the file contained the following: input file Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 I want to read in lines 1-4 for processing then during the next iteratio

RE: Regex parsing question

2003-07-11 Thread Pandey Rajeev-A19514
or will I have to dig deeper in regex fundamentals. Thanks for ur help. Regards Rajeev -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 10:46 PM To: [EMAIL PROTECTED] Subject: Re: Regex parsing question Rob Dixon wrote: > Perl wrote: > >

Re: Regex parsing question

2003-07-11 Thread Rob Dixon
Rob Dixon wrote: > Perl wrote: > > I am attempting to parse a log file that looks something like: > > > > 759033281 TE18 constructor - add to MDBTable > > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > > 759033281 TE18 AddRef=2 > > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > > 75903328

Re: Regex parsing question

2003-07-11 Thread Rob Dixon
Perl wrote: > I am attempting to parse a log file that looks something like: > > 759033281 TE18 constructor - add to MDBTable > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 AddRef=2 > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 S-REXCH-MSG-07 > 75903328

Re: Regex parsing question

2003-07-11 Thread Rob Dixon
Perl wrote: > I am attempting to parse a log file that looks something like: > > 759033281 TE18 constructor - add to MDBTable > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 AddRef=2 > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 S-REXCH-MSG-07 > 75903328

Re: Regex parsing question

2003-07-10 Thread John W. Krahn
Perl wrote: > > I am attempting to parse a log file that looks something like: > > 759033281 TE18 constructor - add to MDBTable > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 AddRef=2 > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD > 759033281 TE18 S-REXCH-MSG-07 > 7590

Regex parsing question

2003-07-10 Thread Perl
I am attempting to parse a log file that looks something like: 759033281 TE18 constructor - add to MDBTable EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD 759033281 TE18 AddRef=2 EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD 759033281 TE18 S-REXCH-MSG-07 759033281 TE18 S-REXCH-MSG-06 7590

RE: Parsing question

2001-10-19 Thread Bob Showalter
> -Original Message- > From: Anderson, Carlin [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 19, 2001 2:53 PM > To: '[EMAIL PROTECTED]' > Subject: Parsing question > > > We are integrating with the Yahoo storefront for some > customers, and I am

Parsing question

2001-10-19 Thread Anderson, Carlin
We are integrating with the Yahoo storefront for some customers, and I am having a problem accessing some of the data elements within the data stream. This is a dump of the raw information dumped by my program: Bill-Address1 = 5575 North Service Road Bill-Address2 = 4th Floor Bill-City = Burling

Re: [beginner] file parsing question

2001-04-24 Thread M.W. Koskamp
- Original Message - From: Stout, Joel R <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, April 24, 2001 10:20 PM Subject: [beginner] file parsing question > Sorry so lengthy but here goes: > > I am a Perl newbie and trying to parse a file. Dependi

Re: [beginner] file parsing question

2001-04-24 Thread Paul
--- Timothy Kimball <[EMAIL PROTECTED]> wrote: > Ah, yes, one of the most frustrating bugs in the world: > : if ($REFln[1] = "SN") { > This *assigns* the value "SN" to $REFln[1]. What you want to do is > *test* it. String comparisons in Perl are done with "eq" (and numeric > comparisons with

Re: [beginner] file parsing question

2001-04-24 Thread Paul Johnson
On Tue, Apr 24, 2001 at 04:33:00PM -0400, Timothy Kimball wrote: > You can avoid this by always writing comparisons with the constant > (if there is one) on the left-hand side: > > if ("SN" eq $REFln) > > but I rarely see people actually do that. I think that's because it feels so unnatu

Re: [beginner] file parsing question

2001-04-24 Thread Kevin Meltzer
Hi Joel, Did you type this in by hand? :) > parseRef ($testln); > sub parseREF { You would want to change one of those! Anyways.. Your problem is in this line: > if ($REFln[1] = "SN") { = is for assignments. You want this to be: if ($REFln[1] eq "SN") { To lear

Re: [beginner] file parsing question

2001-04-24 Thread Timothy Kimball
Ah, yes, one of the most frustrating bugs in the world: : if ($REFln[1] = "SN") { This *assigns* the value "SN" to $REFln[1]. What you want to do is *test* it. String comparisons in Perl are done with "eq" (and numeric comparisons with "=="). So you want this: if ($REFln eq "SN")

[beginner] file parsing question

2001-04-24 Thread Stout, Joel R
Sorry so lengthy but here goes: I am a Perl newbie and trying to parse a file. Depending on the tags in the data I want to parse each line a different way. I built the following program to test my process. use strict; my (@lines, $testln, @REFln); while (<>) { chomp; testType