#!/usr/bin/perl use strict; use warnings; my $string = "00XXX.000XX.00XXX.0000.0000"; $string =~ tr/0.//d; print $string;