AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
grep BLOCK LIST
grep EXPR,LIST

Evaluates the BLOCK or EXPR for each element of LIST (locally setting
$_ to each element) and returns the list value consisting of those
elements for which the expression evaluated to TRUE.  In a scalar
context, returns the number of times the expression was TRUE.

@foo = grep(!/^#/, @bar);    # weed out comments

or equivalently,

@foo = grep {!/^#/} @bar;    # weed out comments

Note that, since $_ is a reference into the list value, it can be used
to modify the elements of the array.  While this is useful and
supported, it can cause bizarre results if the LIST is not a named
array.


[sh-index] Back to list of manuals