> 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 t
#!/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 $h
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_
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
>> 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
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 ) {
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.
>
> "CS" == Curt Shaffer 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.
> "CS" == Curt Shaffer 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 www.microsoft.com -
>
>
> 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 so
>
>
>
> 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=
sec
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 numeric
> "CS" == Curt Shaffer 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 like to
> "CS" == Curt Shaffer 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
> "SB" == Steve Bertrand 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 to grab
so
On Wed, Feb 3, 2010 at 9:22 PM, Tony Esposito
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 table
> }
>
> how do
16 matches
Mail list logo