Re: sequential value check

2010-02-09 Thread Curt Shaffer
URI still no warnings and strict. USE THEM. do it now. add them and declare all your variables. it will save your ass. I am running -w when I run the code. URI what is the \ doing there. it makes the space into a space. it is not seen by split or the regex engine. This is the ONLY

Re: sequential value check

2010-02-09 Thread Curt Shaffer
#!/usr/bin/perl use warnings; use strict; my $hping; my $hping_compare; my @hping_array = (); for (1 .. 5){ $hping = `sudo hping3 www.microsoft.com -S -p 80 -c 1`; push @hping_array,(split'\ ',$hping)[15]; } $hping_compare = $hping_array[0]; foreach (@hping_array){ if ($_ le

Re: sequential value check

2010-02-09 Thread Steve Bertrand
Curt Shaffer wrote: #!/usr/bin/perl use warnings; use strict; my $hping; my $hping_compare; my @hping_array = (); for (1 .. 5){ $hping = `sudo hping3 www.microsoft.com -S -p 80 -c 1`; push @hping_array,(split'\ ',$hping)[15]; } $hping_compare = $hping_array[0];

Re: sequential value check

2010-02-09 Thread Steve Bertrand
Steve Bertrand wrote: Curt Shaffer wrote: #!/usr/bin/perl use warnings; use strict; my $hping; my $hping_compare; my @hping_array = (); for (1 .. 5){ $hping = `sudo hping3 www.microsoft.com -S -p 80 -c 1`; push @hping_array,(split'\ ',$hping)[15]; } $hping_compare =

Re: sequential value check

2010-02-09 Thread Curt Shaffer
SB # ignoring the fact that you were advised to use named variables # instead of $_ where possible, here is one way to do it: I do not see how I can get away from using $_ because each iteration through the loop will be a different variable and thus a different array element. This is why I

Re: sequential value check

2010-02-09 Thread Steve Bertrand
Uri Guttman wrote: CS foreach (@hping_array){ foreach my $ping ( @hping_array){ Uri showed right above how to avoid using $_. eg instead of: foreach ( @hping_array ) { $_ + 10; #...60 lines of code print $_\n; } do: for my $ping_result ( @hping_array ) {

Re: sequential value check

2010-02-09 Thread Curt Shaffer
On Feb 9, 2010, at 10:10 AM, Steve Bertrand wrote: Uri Guttman wrote: CS foreach (@hping_array){ foreach my $ping ( @hping_array){ Uri showed right above how to avoid using $_. eg instead of: I didn't read/understand that fully as to the problem at hand. I apologize. You will

Re: sequential value check

2010-02-09 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: URI still no warnings and strict. USE THEM. do it now. add them and declare all your variables. it will save your ass. CS I am running -w when I run the code. URI what is the \ doing there. it makes the space into a space.

Re: sequential value check

2010-02-09 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS #!/usr/bin/perl CS use warnings; CS use strict; CS my $hping; CS my $hping_compare; CS my @hping_array = (); no need for the = () as all arrays are created empty. CS for (1 .. 5){ CS $hping = `sudo hping3

Re: sequential value check

2010-02-09 Thread Curt Shaffer
Uri no need for the = () as all arrays are created empty. I wasn't sure if strict would bark or not, so I figured better safe than sorry. Uri someone told you that le is wrong for numeric comparison. and WHAT do you think is in $_ there? you never explicitly set it. it may have some

Re: sequential value check

2010-02-09 Thread Curt Shaffer
Uri post the output line from that command. do not let your emailer mung it or word wrap it. show the part you want to extract out. there may be easier ways to get it with a regex and not with split. I think you may be right. I would like to pull the numerics out from the id= section.

Re: sequential value check

2010-02-09 Thread Steve Bertrand
Curt Shaffer wrote: Uri post the output line from that command. do not let your emailer mung it or word wrap it. show the part you want to extract out. there may be easier ways to get it with a regex and not with split. I think you may be right. I would like to pull the numerics out from

Re: sequential value check

2010-02-09 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: Uri post the output line from that command. do not let your emailer mung it or word wrap it. show the part you want to extract out. there may be easier ways to get it with a regex and not with split. CS I think you may be right. I would

Re: sequential value check

2010-02-09 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: Uri no need for the = () as all arrays are created empty. CS I wasn't sure if strict would bark or not, so I figured better safe than sorry. Uri someone told you that le is wrong for numeric comparison. and WHAT do you think is

Re: sequential value check

2010-02-09 Thread Uri Guttman
SB == Steve Bertrand st...@ibctech.ca writes: SB $ping_result =~ m{ .* id=(\d+) }xms; that will match 'grid=123' or 'foo=34 noid=123' etc. the .* is allowing anything before the id. it may work here as no field other than id ends in 'id' but it is a poor regex. don't use *. unless you mean

sequential value check

2010-02-08 Thread Curt Shaffer
I'm trying to figure out a way to compare a couple values to see if they are sequential or not. I'm running a for loop and grabbing a value and setting a variable through each iteration. At the end I would like to examine the results and see if they are sequential or not. If the values are

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS I'm trying to figure out a way to compare a couple values to see CS if they are sequential or not. I'm running a for loop and CS grabbing a value and setting a variable through each iteration. At CS the end I would like to examine the

Re: sequential value check

2010-02-08 Thread Curt Shaffer
OK. So I have tried some things. I guess the largest issue that I can't find an answer for elsewhere is how to evaluate variables to be , = or 100 in one evaluation. Before I get there, obviously I need to get the variables. Here is what I am trying to do for that: @hping_array = (); $hcount

Re: sequential value check

2010-02-08 Thread Jim Gibson
On 2/8/10 Mon Feb 8, 2010 3:55 PM, Curt Shaffer cshaf...@gmail.com scribbled: OK. So I have tried some things. I guess the largest issue that I can't find an answer for elsewhere is how to evaluate variables to be , = or 100 in one evaluation. Before I get there, obviously I need to get

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS OK. So I have tried some things. I guess the largest issue that I CS can't find an answer for elsewhere is how to evaluate variables to CS be , = or 100 in one evaluation. Before I get there, obviously CS I need to get the variables.

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Thanks Jim. I see my error now. I didn't realize you could just backtick in a for like that. On Feb 8, 2010, at 7:06 PM, Jim Gibson wrote: On 2/8/10 Mon Feb 8, 2010 3:55 PM, Curt Shaffer cshaf...@gmail.com scribbled: OK. So I have tried some things. I guess the largest issue that I

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Thanks for the clue. I have narrowed some things down. The counter is much nicer. I just need to get a better split I think as I'm not getting the grouping I would like. On Feb 8, 2010, at 7:19 PM, Uri Guttman wrote: CS == Curt Shaffer cshaf...@gmail.com writes: CS OK. So I have tried

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Ok. So again, thanks for getting me on the right track. I am now at my compare routine. This is where I cannot figure out how to compare within 100. My first instinct is to write something like the following: #!/usr/bin/perl -w for (1 .. 5){ my $hping = `sudo hping3 www.microsoft.com

Re: sequential value check

2010-02-08 Thread Jim Gibson
At 9:17 PM -0500 2/8/10, Curt Shaffer wrote: Ok. So again, thanks for getting me on the right track. I am now at my compare routine. This is where I cannot figure out how to compare within 100. My first instinct is to write something like the following: #!/usr/bin/perl -w for (1 .. 5){ I

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS #!/usr/bin/perl -w still no warnings and strict. USE THEM. do it now. add them and declare all your variables. it will save your ass. CS for (1 .. 5){ CS my $hping = `sudo hping3 www.microsoft.com -S -p 80 -c 1`; CS