Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: searching in array

by kwoff (Friar)
on Dec 10, 2001 at 21:52 UTC ( #130723=note: print w/replies, xml ) Need Help??


in reply to searching in array

I assume you meant
@arr = qw(test1 @test2 @test3 test4 test5);
In that case, you can use grep
$str1 = join(',', grep {/^@/} @arr); $str2 = join(',', grep {/^[^@]/} @arr);
Or you could use a foreach loop, push onto either of two arrays depending on the match, then join afterward.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://130723]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-05-20 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?