I have written this little app, really just for somthing to. but I keep getting the following error.
Use of uninitialized value in pattern match (m//) at ./usercheck.pl li +ne 35. Use of uninitialized value in pattern match (m//) at ./usercheck.pl li +ne 35.
Repeated a rather large amount of times. I think that @source is not beening assigned any values? and using perl -d did not reap much help but im still learning my way round the debuger.
#!/usr/bin/perl -w # by n00dles use IO::Socket; use strict; my $target = 'localhost'; my $userlist = 'uselist.txt'; my $timeout = 40; print "Content-type: text/html\n\n"; print "<BODY BGCOLOR=#000000 Text=#008000 link=#00c000 vlink=lightblue +>"; print "<PRE>\n"; print "<H2>Active Apache user accounts</H2>\n\n"; print "<B>Loading from file $userlist</B>\n"; open(USERS, "< $userlist") or die "cannot open file: $!\n"; my @users =<USERS>; close(USERS); print "<B>User list $userlist loaded!</B>\n"; print "<B>Starting Scan please wait...</B>\n"; for (my $i = 0; $i < scalar(@users); $i++) { my $socket = new IO::Socket::INET ( peerAddr => $target, peerPort => '80', Proto => 'tcp', Timeout => $timeout,); die "Socket failed at $target\n" unless $socket; print $socket "GET http://$target/~$users[$i] HTTP/1.0\r\n\r\n +"; my @source = <$socket>; foreach my $line ($source[2]) { if ($line =~/302 Found/ || $line =~ /200 OK/ || $line +=~ /403 Forbidden/ || $line =~ /301 Moved Permanetly/) { print "Found: $users[$i]"; } } close($socket); } print "</BODY></HTML>";
Any wisdom you can offer would be greatly recived. I have made a command-line version of this app that uses @ARGV to take the target and userlist from the prompt witch works fine, but this version does not.

2006-09-03 Retitled by g0n, as per Monastery guidelines
Original title: 'Completely lost :('


In reply to Completely lost - 'Use of uninitialized value in pattern match...' error :( by n00dles

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.