{ local $/ = chr 0; chomp $your_string; } # or $your_string =~ s/\x00\z//;