in reply to strange shift @_ problem

Ok, you have a little mistake here.. It's all in "Case2":

my $Rubbish=join "",(split //,shift)[$_[1]..$_[2]];

Ok, before that you have $_[0], $_1 and $_2. Then you shift. That means that you take the first value ($_[0]), end delete it. So $_1 becomes $_[0] and $_2 becomes $_1. And since there wasn't a $_3 there won't be a $_2 after that.
If you alter the line to the following it should work:

my $Rubbish=join "",(split //,shift)[$_[0]..$_[1]];
sorry, i made a mistake.. this WON'T work! see below..
Regards, octopus -- GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+

Replies are listed 'Best First'.
Re: Re: strange shift @_ problem
by ChOas (Curate) on Jan 18, 2001 at 17:10 UTC
    Thanks, but it doesn't help ;)))

    Because it DOES work the way it is written,
    and the way you write it, it tries to use the string
    as the first index of the slice on the thing ;)))

    ahunter had a great point there...

    but.. This IS the first time Perl does something I DON'T
    expect ;))

    GreetZ!,
      ChOas

    print "profeth still\n" if /bird|devil/;
      Hm, I think I see now what you mean. You can access $_2 in that line I posted but not after that line was processed.
      AFAIK, perl replaces all variables first (like $_2) and then processes the commands (like shift). That would result in:
      First $_2 was replaced with it's value (3 or 5 or whatever), and then perl uses the shift command and there is no $_2 no more..
      Maybe that helps!?

      Regards, octopus
      --
      GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+