in reply to Remove nulls, or other Chars

There is a way indeed. Your approach doesn't work because tr/// returns the number of transliterations (or in your case, removals), and map collects return values. So you need to actually return $_
use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq = 1; my @a = ("a\000b\000c", "foo\000bar"); print Dumper \@a; my @cleaned = map {tr/\000//d; $_ } @a; print Dumper \@cleaned;

Please note that a common cause for null bytes is the use of UTF-16; if that's the case, don't remove the null bytes, but decode the strings.

Replies are listed 'Best First'.
Re^2: Remove nulls, or other Chars
by Saved (Beadle) on Apr 01, 2011 at 14:26 UTC
    Thank You for explaination & Solution