for ([split /(\s+)/, $str]) { shift @$_ if $_->[0] eq ''; my ($s,$e)= do { my @c=@$_; map $_ + ($c[$_] =~ /\s/ ? ($_ >=0 ? 1 : -1 ) : 0) => 0, -1; }; $_->[$s] ^= $_->[$e]; $_->[$e] ^= $_->[$s]; $_->[$s] ^= $_->[$e]; y/\0//d for @$_; local $"=''; print "@$_"; }