i need a way to represent an ip when scanning a c-range for web server info.
use IO::Socket; my $first_var = "64.219.21.1"; my $last_var = "25"; my ($net,$first) = ($first_var =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3})\.(\d +{1,3})$/ ); die "undetermined network part in $first_var.\n" unless $net; die "undetermined host part in $first_var.\n" unless $first; my ($last) = ($last_var =~ /^(\d{1,3})$/ ); die "undetermined host part in $last_var.\n" unless $last; ($last, $first) = ($first, $last) if $last < $first; my @hosts = ($first..$last); for ($li=0;$li<=$#hosts;$li++){ &scan() }
if scan() contains print "$net.$hosts[$li]"; it executes perfectly, printing out all the ip's with no newlines or anything. but let's say this is scan:
sub scan { $host = "$net.$hosts[$li]"; $socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => 80) or die $!; $socket->autoflush(1); print $socket "HEAD / HTTP/1.0\015\012\015\012"; while (<$socket>) { print; last if /^$/; } close($socket); }
this gives an unknown error. i tried replacing $host with the url "feartech.net" it performed perfectly. so i suppose my question is, how to express the ip in a manner that the connection will go through. thanks for your help.

In reply to socket problems by common

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.