On Nov 8, Mark Johnson said:

>my @results = ExecCommand( $someCommand, 1 );
>&PrintResults( @results );
>
>sub ExecCommand( $command, $waitForPrompt )

Ugh, you're so lucky Perl doesn't bark at you.  Perl's functions do not
work like this.  You're very lucky you didn't define those functions
before using them, or you'd have been told you had a malformed prototype.

Don't use ()'s when defining a subroutine.

  sub ExecCommand { ... }

>   my @results = shift;

Do you know what shift() does?  It takes off the first element of the @_
array (the arguments to the function) and returns it.  You're doing that
here.  Perhaps you wanted

  my @results = @_;

or better yet, don't use @results.  Just use @_ directly.

Function arguments are squashed into one big list.  You can't
differentiate between passing three scalars to a function, or sending an
array of three elements.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to