@a = ( 'a', 'x', 'z' ); # simplified array { # restrict scope of changes to $, local $"=''; # change from default space to null string while(<>) { print if(/^[@a]{3}$/); } }