in reply to Invalid argument

Hi Andrew_Levenson, Yes, it's because you have a newline at the end of your arguments.

Note what happens when you do:

print "Debug: Arguments are $_[0] and $_[1]\n";

Read about chop and chomp for more information on how to remove newlines.

Here's a better implementation of what you're trying to do (note that chomp only removes the last character if it's a newline):

chomp(my $arg1 = shift || <>); chomp(my $arg2 = shift || <>);

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Invalid argument
by Andrew_Levenson (Hermit) on Dec 01, 2006 at 20:21 UTC
    Liverpole -- I know I have a newline in my arguments, but I also have them being chomped in the subroutine. :-\
    That's why i'm so confused.
      Whoops -- didn't read that far :-/

      It's because you're not passing @_.

      You could fix this with:

      handlefix(@_);
      but it's really better practice to chomp the variables on input, and assign them to actual variable names, leaving @_ to its better purpose of the default argument list.

      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      Because handlefix(); sends nothing to @_ in your sub.

      Take a look at perlsub, @_ is local

      grep
      XP matters not. Look at me. Judge me by my XP, do you?