in reply to Re^2: Is it possible to store an arthimetric operator in a variable?
in thread Is it possible to store an arthimetric operator in a variable?
Sure, I could do that for you.
This is how you would normally define a sub:
sub something { ... }
This would be a sub stored in a variable:
my $thing = sub { ... }
So sub { $_[0] == $_[1] } is a sub stored in a variable.
Now what I think you're really asking is the $_[0] part. When you have a sub, the variable @_ contains all of your inputs to that sub. So if you call:
mysub( $one, $two );
Then @_ holds $one and $two, or:
@_ = ( $one, $two );
Since this is an array, you can get at the first variable with $_[0] and the second variable with $_[1]. Does that make sense?
Also, check out perlsub for a better explanation.
-Bryan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Is it possible to store an arthimetric operator in a variable?
by Anonymous Monk on Jul 19, 2005 at 14:45 UTC |