@arr = qw(test1 @test2 @test3 test4 test5); #### $str1 = join(',', grep {/^@/} @arr); $str2 = join(',', grep {/^[^@]/} @arr);