in reply to Getting a grip on grep

What's happening I think is that merlyn was giving you an example of the usage of the UNIX system command grep. grep() in Perl is different: the syntax is: grep PATTERN, LIST or grep BLOCK LIST You'll have to write the returned array to file yourself, because grep() doesn't support redirection (as does any Perl function...)

--
my @words = grep({ref} @clever);
sub version { print "I cuss your capitalist pig tendencies bad!\n" }

Replies are listed 'Best First'.
Re: Re: Getting a grip on codegrep/code
by japhy (Canon) on Sep 26, 2001 at 20:13 UTC
    grep() is not solely a regex tool. It actually takes ANY expression you give it:
    # grep EXPR, LIST @biggish = grep $_ > 10, @numbers;

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      Cool, I didn't know that but it makes sense. Thanks.

      --
      my @words = grep({ref} @clever);
      sub version { print "I cuss your capitalist pig tendencies bad!\n" }