A question about lists

Discussion in 'Perl Misc' started by grocery_stocker, May 9, 2007.

  1. 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
    grocery_stocker, May 9, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JustSomeGuy

    Sorting lists of lists...

    JustSomeGuy, Jun 17, 2004, in forum: C++
    Replies:
    0
    Views:
    305
    JustSomeGuy
    Jun 17, 2004
  2. Jon Slaughter

    lists of lists

    Jon Slaughter, Dec 13, 2004, in forum: C++
    Replies:
    4
    Views:
    405
    Buster
    Dec 13, 2004
  3. Charlotte Henkle

    Counter for items in lists in lists?

    Charlotte Henkle, Sep 25, 2004, in forum: Python
    Replies:
    8
    Views:
    390
    Charlotte Henkle
    Sep 26, 2004
  4. robin
    Replies:
    10
    Views:
    531
    Dave Hansen
    Apr 12, 2006
  5. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    384
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
Loading...

Share This Page