in reply to removing a character from a string

Do like this:
my $string = '123-4567'; $string =~ s/-//g; print $string;
s/<search>/<replace>/g; # the 'g' replaces every occurrence of <search>, not just the first.

Update: This'll work, too:

my $i='123-4567'; my $j; while( length($i) ){ $j .= chop( $i ); chop $j if substr( $j, -1 ) eq '-'; } print reverse split //, $j;

Replies are listed 'Best First'.
Re: Re: removing a character from a string
by bobothesmart (Initiate) on Jun 18, 2002 at 20:02 UTC
    Thanks :D