in reply to how to save result in multiple files using for loop in perl
You didn't mention in what way(s) it's not working. That's important info for anyone trying to help you debug.
One issue I noticed is that you're going to run passed the end of @dude. The scalar value returned by @dude is the number of elements it contains. @dude+1 is one more than the number of elements.
Another issue is here: file"+"$0.txt ". Perl doesn't concatenate strings using '+'. It uses the dot operator for that. But it's not even necessary. You could write it as file$0.txt".
Here's a reworked version. I won't be debugging your system call, and don't know if it's even an issue:
use strict; use warnings; open FILE, '<', "dns.txt" or die $!; while (my $line = <FILE>) { my ($ip) = $line =~ /(\d+\.\d+\.\d+\.\d+)/; system("ssh a.AS1 traceroute $ip > file$ip.txt"); }
Dave
|
|---|