use strict; use warnings; use Data::Dumper; my @array = (1,0,1); for my $item (@array) { $item = !$item + 0; } print Dumper(\@array);