in reply to hex in regexp

Like this

use CGI; my $freeStuff = CGI->escape( $stuff );

or this

use JSON; my $freeStuff = JSON->new->ascii(1)->pretty(1)->encode([ $stuff ]);

Replies are listed 'Best First'.
Re^2: hex in regexp
by shamanoff (Initiate) on May 22, 2012 at 04:36 UTC

    Sorry, I did not understand your answer at all. You see, I just started to learn Perl and sometimes may not recognize the value of the example shown. My task is to get rid of the non-Ascii symbols which were mixed with Ascii symbols in text file with multiple rows. I am not sure that solutions mentioned in the first reply do the trick. (what is the meaning of $freeStuff and $stuff anyway...). Could you please provide more vivid example or direction.

      See, I assumed an XY Problem . I assumed what you really wanted to do was use an already existing encoder/serializer, instead of inventing your own, so I showed you two which use hex encoded characters. One which only does strings (CGI->escape) and one which does complex data structures (JSON)

      I guess since this might be homework a practical solution doesn't fit :)