Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: how do I test against each element in an array

by kilinrax (Deacon)
on Nov 07, 2000 at 22:45 UTC ( [id://40383]=note: print w/replies, xml ) Need Help??


in reply to how do I test against each element in an array

This works on my system, (linux, so you'll need to tweak the locations of things), though it's a bit of a kludge.
#!/usr/bin/perl -w open NAMES, "names.txt" or die "Cannot open names file"; while (<NAMES>) { chomp; my $ping = `ping -c 1 $_`; if ($ping =~ /\((\d+\.\d+\.\d+\.\d+)\)/) { my $ip = $1; open TESTED, '>>tested.txt'; print TESTED "$ip\n"; close TESTED; } else { warn "Cannot deciper result of \"ping $_\""; } } close NAMES; exit 0;

Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://40383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found