Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Reading IP from a file and SNMP

by theroninwins (Friar)
on Aug 26, 2004 at 13:50 UTC ( #386019=note: print w/replies, xml ) Need Help??


in reply to Re: Reading IP from a file and SNMP
in thread Reading IP from a file and SNMP

There is still the question of the reading of the IPs in the file?? Thanks for wellcoming me and for the help already... I got some interseting piece of code :-) just got to understand it now.

Replies are listed 'Best First'.
Re^3: Reading IP from a file and SNMP
by radiantmatrix (Parson) on Aug 26, 2004 at 14:06 UTC
    I highly suggest getting copies of Learning Perl, Programming Perl, and The Perl Cookbook.

    To get you started, you can read files like this:

    open FH, '<', $filename or die ("Can't open $filename"); #FH is a "filehandle", and the '<' means "open in read mode" #('>' would be write) while (<FH>) { #the angles around FH mean "read a line" work_with_the_line($_); # $_ holds the current line in this case # work_with_the_line would be a subroutine defined by you } close FH; #don't forget to close files!
    Much perl code is out there "in the wild", I highly suggest searching to see if someone has solved a similar problem, then reading and learning from their source.
    --
    $me = rand($hacker{perl});
Re^3: Reading IP from a file and SNMP
by habit_forming (Monk) on Aug 26, 2004 at 14:11 UTC
    Well it depends on how they are stored in the file. If there is only one IP per line, this code will do:
    my @ip_array = (); if(open(F_IP,"<$filename")) { my %ip_hash = (); foreach my $ip (<F_IP>) { chomp($ip); #No duplicates! $ip_hash{$ip} = 1; } close(F_IP); @ip_array = keys(%ip_hash); } else { die "AHHHHH! Error Error go away!!"; } #Just keep doing your thing man...


    Note that I wrote this on the fly and have not tested it. It should give you a good start though. =)

    --habit

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-05-29 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?