$script=~s/(\W)/_/g; #### my $script = "cos.NEW&OLD.0826.12345"; $script=~s/\&/_/; print "$script"; #outputs "cos.NEW_OLD.0826.12345"