http://qs1969.pair.com?node_id=130723


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.