in reply to Incorporating each while loop and email into one loop?
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:
For more on functions, try perldoc perlsub.# 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");
UPDATE
BTW rather than manually calling sendmail, I would recommend
using Mail::Send.
|
|---|