in reply to Incorporating each while loop and email into one loop?

I strongly recommend going through your code, trying to identify logical "chunks", and pulling them into functions. After you have done that, you will wind up with more maintainable code.

As a side benefit it should then be easy to take the body of your code and turn it into a function that takes an IP address as a parameter. Then you can solve your original problem by calling your function 10 times in a loop.

In case you don't know how to write a function in Perl, you just do it very simply like this:

# declare a function sub my_function_name { # Your input parameters will be in the array @_... my $first_arg = shift(@_); my @remaining args = @_; # Then do whatever you want here... print "Hello, world\n"; # And return data return "Whatever you want to\n"; } # And then you call it like this: my_function_name("First argument", "the", "rest", "of", "them");
For more on functions, try perldoc perlsub.

UPDATE
BTW rather than manually calling sendmail, I would recommend using Mail::Send.

  • Comment on Re (tilly) 1: Incorporating each while loop and email into one loop?
  • Download Code