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

Re: prepare(SELECT ... FROM TABLE) error

2010-02-09 Thread Jay Savage
On Wed, Feb 3, 2010 at 9:22 PM, Tony Esposito tony1234567...@yahoo.co.uk wrote: This question has never been answered.  To out it another way, given the code ...  foreach my $mytable (@mytables) {  my $sth = $dbh-prepare(SELECT COUNT(*) FROM mytable);  # report error but move on to next