in reply to grep usage confusion

why ($index) needs to be written in bracket for the grep to return an appropriate index number?

my $index returns a scalar and thus creates a scalar context.
In scalar context, grep returns the number of matching items (which is not what you want).

my ($index) returns a list and thus creates a list context.
In list context, grep returns the matching items (where your code assigns the first one).

why can grep's 2nd parameter be either an array or sequence of array index?

You are mistaken in thinking the 2nd parameter is an array or sequence. You are passing a whole list of arguments.

Since
0 .. $#coins
returns
0, 1, 2
then
my ($index) = grep($coins[$_] eq "fourthy", 0 .. $#coins);
is the same as
my ($index) = grep($coins[$_] eq "fourthy", 0, 1, 2);

Since
@coins
returns
$coins[0], $coins[1], $coins[2]
then
my @index2 = grep($_ ne "fourthy", @coins);
is the same as
my @index2 = grep($_ ne "fourthy", $coins[0], $coins[1], $coins[2]);

This has nothing to do with grep. The expressions @coins and 0..$#coins are evaluated before grep is even called.

>perl -le"$,=','; print @ARGV" twenty thirty forty twenty,thirthy,fourthy >perl -le"$,=','; print 0..$#ARGV" twenty thirty forty 0,1,2

By the way, you misspelled "thirty" and "forty".

both grep's $_ symbol seems to work differently..is this dependent on the 2nd parameter of grep? one works as a key, another as a value!

The first time the first argument is executed, $_ is aliased to the second argument.
The second time the first argument is executed, $_ is aliased to the third argument.
The third the first argument is executed, $_ is aliased to the fourth argument.
And so on.

There's no such things as keys and values, just the list of arguments you passed to grep.