develooper Front page | perl.beginners | Postings from March 2002

Re: A question about strings and hexadecimal numbers of special characters

Thread Previous
From:
Jan Gruber
Date:
March 6, 2002 03:47
Subject:
Re: A question about strings and hexadecimal numbers of special characters
Message ID:
200203061146.g26BkWr16795@pollux.intern.primacom.net
Hi O && List !


On Wednesday 06 March 2002 11:41 am, you wrote:
> I'm very new to Perl and have a basic question. How can I convert special
> characters contained in a string to hexadesimal numbers. 

sub HTMLify {

  my $what = shift;
  $what =~ s/(\W)/sprintf("%%%x", ord($1))/eg;
  
  return $what;
  
}

HTH,
Jan
-- 
cat /dev/world | perl -e "while (<>) {(/(^.*? \?) 42 \!/) && (print $1)}"
errors->(c)
_ 

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About