in reply to Re: Lewis Carroll's Code
in thread Lewis Carroll's Code

grep may be what you are looking for. it uses a regex rather than a string though:

From the perldoc:

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 regular expressions. Evaluates the BLOCK or EXPR for each element of LIST (locally setting "$_" to each element) and returns the list value consisting of those ele­ments 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

Hope that helps
Chris

Lobster Aliens Are attacking the world!

Replies are listed 'Best First'.
Re: Re: Re: Lewis Carroll's Code
by Cody Pendant (Prior) on Jul 18, 2002 at 04:25 UTC
    I'm confused -- what is it you want me to use GREP for?
    --
    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;

      Sorry, I was saying that you could use grep() on an array like you would use index() on a string, its not exactly the same though.... I think I better go to bed I'm not making much sense and I'm getting myself downvoted :)

      Lobster Aliens Are attacking the world!