Hi. This is my first real perl script, and I am somewhat clueless. I intended it to monitor a number of given AIM screennames for activity (logging in, out, etc) and logging this activity to a file. Needless to say, it doesn't run. Correctly, at least. Can anyone help me out? Thanks...
#!/usr/bin/perl -w use Net::AIMTOC; use Term::ReadKey; $version = 0.01; #The version number $screenname = ""; #Contains the screenname for logging in $password = ""; #Password for logging in $out = "STDOUT"; #Set default output to the screen @targets; #Array containing screennames to watch # process($) # Takes next argument as parameter. # Checks to see if it's a flag, otherwise # considers it a screenname and adds to list. sub process_args($) { my $iterate = 0; #Local variable for adding to @targets if ($_[0] eq "-v" || $_[0] eq "--version") { print "Thanks for supporting AimSpy. You are currently using +version $version of AimSpy.\n"; } elsif ($_[0] eq "-h" || $_[0] eq "--help") { } #help info elsif ($_[0] eq "-o") { #check for output file spec. $save = shift @ARGV; open($out = SAVE, ">>$save") or open($out = SAVE, ">$save") or die "Can't save to file $save: $!\n"; } elsif ($_[0] eq "-i") { #check for input file spec. $read = shift @ARGV; open(INPUT, "$read") or die "Could not open file: $!\n"; $iterate = 0; while(<INPUT>) { $targets[$iterate] = $_; $iterate++; } } else { #everything else is a screenname $targets[$iterate] = $_[0]; $iterate++; } } # login() # Logs in to AIM. Prompts sn and pw. # Establishes connection to AOL. # Doesn't really do too much else.... sub login() { if (!@ARGV) { #We need someone to spy on. die "No targets specified!"; } if ($screenname eq "") { print "Enter your screenname: "; chomp($screenname = <STDIN>); print "\nEnter your password: "; ReadMode 2; chomp($password = <STDIN>); ReadMode 0; } try { $aim = Net::AIMTOC->new; $aim->connect; $aim->sign_on($screenname, $password); } catch Net::AIMTOC::Error with { my $err = shift; print $err->stringify, "\n"; }; foreach my $iterate (@targets) { $aim->add_online_buddies("aimspy", $iterate); } } sub monitor() { while (1) { my $msg = $aim->recv_from_aol(); if ($msg->getType eq 'UPDATE_BUDDY' && $msg->getBuddy eq @targ +ets) { print $out $msg->getBuddy, " turned ", $msg-getOnlineStatu +s, " at this time.\n"; } elsif ($msg->getType eq 'IM_IN') { print $out "Message ", $msg->getMsg, " received from ", $m +sg->getSender, " at this time.\n"; } elsif ($msg->getType eq 'ERROR') { print $out "Error ", $msg->getMsg, " received at this time +.\n"; } } } while (@ARGV) { #process arguments process_args(shift @ARGV); } login; monitor;

In reply to Script help by Deleuze

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.