use Data::Dumper; my @test=("aaa bbbbb cccc"); my @test = map { s/\s//g; $_ } @test; print Dumper(\@test); #### $VAR1 = [ 'aaabbbbbcccc' ];