in reply to Manipulating multiple matches

Like this?

my $string = "&#15123 la di da &#32714 do bi do &#04271" ; print map { chr } $string =~ /&#(\d\d\d\d\d)/g ;

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: Manipulating multiple matches
by Anonymous Monk on Aug 15, 2002 at 07:09 UTC
    Yes, that works well. However I need to manipulate them (such as you just did) and then replace the match with the newly manipulated part. So that each of the "&#\d\d\d\d\d" becomes chr(\d\d\d\d\d) in the string.
      $string =~ s{&#(\d{5})}{chr( $1 )}ge ;

      _______________
      DamnDirtyApe
      Those who know that they are profound strive for clarity. Those who
      would like to seem profound to the crowd strive for obscurity.
                  --Friedrich Nietzsche
      Try this
      my $string = "&#15123 la di da &#32714 do bi do &#04271" ; $string =~ s/&#(\d\d\d\d\d)/chr($1)/ge ; print "$string\n"
      Hope that helps.