Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks, I know that you do not like lazy person and use expertise for simple stuff. Since I am a newbie and try to accomplish a task that is quite advance, if you do not mind, I would like get a help from you again. I am trying to read a bardcode from a serail port. However I am getting nonprinting extented ascii character and try to replace them with meaningful one eg. "50003903363" replace "" with "4". As you can imagine I could not figure it out. I am using a below command to do it, but it cannot recognize "" that is Chr 180. $Buffer =~ s/(char 180)/4/eg ; Regards,
  • Comment on string matching with extented ASCII characters

Replies are listed 'Best First'.
Re: string matching with extented ASCII characters
by zakb (Pilgrim) on Jun 11, 2003 at 08:40 UTC

    Well, if that "" really is chr(180), then you can find it like this:

    $Buffer =~ s/\xb4/4/g;

    \x takes a hex code. See perlretut or perlre.

      thanks zakb, actually the char(180) was not printed write in the message but \xb4 simply solved the issue. Thanks again.
Re: string matching with extented ASCII characters
by CountZero (Bishop) on Jun 11, 2003 at 09:43 UTC

    Just being curious, why would s/,,/4/g not work?


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Because ,, is not chr(180).

      Update: see here.