in reply to Re^2: Using a Regexp to match a string exactly
in thread Using a Regexp to match a string exactly
The generic variable $_ holds the value of the current item from the list. Actually, it's even stronger than that: $_ is an alias to the current item, which means: same value (by reference; you could say: same variable); different name. If you modify $_ in that expression, the original value will have changed. Example:
Result:@original= (0 .. 5); @true = grep $_*=2, @original; local $" = ", "; # for nicely formatted output print "original: @original\n"; print "output: @true\n";
original: 0, 2, 4, 6, 8, 10 output: 2, 4, 6, 8, 10
Each item in the original array has been doubled. Of those, only the nonzero (true) values have been come through the grep filter.
|
|---|