Hello,
I am still very very new to perl and hope such
a newbie question will go un-punished.
I get emails consisting of 3 lines in the body
that are generated by this command....

(uname -a ;uptime ;date) | mail -s uptime time@taproot.bz

I have made a little code that opens the user "times" mail
spool and grabs the next 3 lines after a blank line, this
is to cutout the header and grab the output of the uname
stuff. The script works...i guess, but complains about
Use of uninitialized value in string at ./mail.pl line 15.

Im guessing that the blank line after the body is producing
this....line 15 is trying to call up three more vars
from the @array that are not there when only one mail is
present.. or dealing with the last mail in spool ..
I think.
#! /usr/bin/perl -w $file = "/var/spool/mail/mohadib"; open(MAIL, "$file") || die "cant open spool\n"; @array = <MAIL>; close (MAIL); foreach $array (@array){ if($array !~ /[A-Za-z0-9]/){ @num = (1 .. 3); foreach $num (@num){ $current = $new + $num; print "$array[\"$current\"]"; } } $new++; }

could someone put my logic on the right path :)
maybe I can test for the words Linux or BSD in the
next line after i have matched a blank line
....and exit if not true?
Hope this is coherent,
jd

In reply to Newbie Question - arrays by mohadib_the_nasty

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.