in reply to Passing an array, or not? MIME::Lite

Your code does not pass perl -c. That line with if shall be:

if ($counter >= 1) {$message += $inline . "\n"};
"my $counter = 0; foreach my $inline (@ARGV) { if ($counter >= 1) $message += $inline . "\n"; ++$counter; #a wasting, although not a big one ;-) }"

Looks like the whole purpose of using $counter is to skip the first element, why not just:

for my $index (1 .. $#ARGV) { $message += $ARGV[$index] . "\n"; }

Now why you skip the first element? Try this:

use strict; use warnings; for my $index (0 .. $#ARGV) { print $ARGV[$index] . "\n"; }

Run it with perl -w blah.pl msg1 msg2 msg3, the output is:

msg1 msg2 msg3

What are you try to skip ;-?

Replies are listed 'Best First'.
Re^2: Passing an array, or not? MIME::Lite
by invisible_ink (Initiate) on Oct 11, 2004 at 23:01 UTC
    Thank you, venerable monk. The first input is the one to whom the e-mail is sent. The subsequent input is the message to be sent. That is processed separately.

    So, perl -w blah.pl you@whereyouare.com MessageBodyHere

    I think the question I have is, how can I capture what is processed by /bin/cat (ie the message itself) but not being input into the command-line script? Where am I losing the data?