A question about lists

  • Thread starter grocery_stocker
  • Start date
G

grocery_stocker

Quoting part of perldoc -f grep

"grep BLOCK LIST
grep EXPR,LIST
This is similar in spirit to, but not the same as,
grep(1) and
its relatives. In particular, it is not limited to
using regu-
lar expressions.

Evaluates the BLOCK or EXPR for each element of LIST
(locally
setting $_ to each element) and returns the list value
consist-
ing of those elements for which the expression
evaluated to
true. In 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
"

If @bar is an array, does this get converted to a list automatically?



Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,082
Latest member
KetonaraKetoACV

Latest Threads

Top