Storing $DIGIT variables in arrays
From: Jesse Taylor (jrtaylor_at_tulane.edu)
Date: 01/23/05
- Previous message: Daniel Kasak: "Re: problem with installing DBD::mysql module"
- Next in thread: Graeme St. Clair: "RE: Storing $DIGIT variables in arrays"
- Maybe reply: Graeme St. Clair: "RE: Storing $DIGIT variables in arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 23 Jan 2005 22:20:12 +0000 To: beginners@perl.org
Below I have posted the source for a program I am attempting to write
that will take a list of URL's, grab the pages, and search them for
email addresses and IP addresses, remove duplicate entries, and store
the results in a text file. Everything compiles fine and runs without
any warnings, however my output is not what I expected. When I run it
with this URL in my list: http://gentoo-solid.no-ip.com/testpage.php ,
the output file does not contain either of the actual IP addresses and
instead picks the only one that is NOT an IP address and just takes the
first four numbers "45.45.45.45". The emails are working fine, however
and all show up in the output file. Any help on this would be appreciated.
Thanks,
Jesse Taylor
######--START CODE--######
#!/usr/bin/perl -w
#Given a text file containing URLs, this script will extract any IP
addresses or email address from said URLs
use LWP::Simple;
print "Enter location of URL list file: ";
chomp($infile=<STDIN>);
open INFILE, $infile
or die "Could not open file $infile";
print "Enter location at which to create output file: ";
chomp($outfile=<STDIN>);
open OUTFILE, ">$outfile"
or die "Could not open/create $outfile";
while($url=<INFILE>)
{
chomp($url);
$html=get("$url")
or die "Couldn't open page located at $url";
@ips = $html =~
/(\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255])/g;
#find and store IP addresses
@emails = $html =~ /(\w+\@\w+\.\w+)/g; #find email addresses and
store
push(@allips, @ips);
push(@allemails, @emails);
}
####remove duplicate array members####
for($i=0; $i<(scalar @allips); $i++)
{
for ($j=0; $j<(scalar @allips); $j++)
{
if ($allips[$i] eq $allips[$j] && $i!=$j)
{
splice(@allips, $j, 0);
}
}
}
####remove duplicate array members####
for($i=0; $i<(scalar @allemails); $i++)
{
for ($j=0; $j<(scalar @allemails); $j++)
{
if ($allemails[$i] eq $allemails[$j] && $i!=$j)
{
splice(@allemails, $j, 1);
}
}
}
####Store data in output file####
print OUTFILE "IP Addresses: \n";
foreach (@allips)
{
print OUTFILE "$_\n";
}
print OUTFILE "\nEmail Addresses: \n";
foreach (@allemails)
{
print OUTFILE "$_\n";
}
close(INFILE);
close(OUTFILE);
- Previous message: Daniel Kasak: "Re: problem with installing DBD::mysql module"
- Next in thread: Graeme St. Clair: "RE: Storing $DIGIT variables in arrays"
- Maybe reply: Graeme St. Clair: "RE: Storing $DIGIT variables in arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|