# http://www.cs.dal.ca/~vlado/srcperl/snip/encode_w
# (c) 2005 Vlado Keselj
#
# A way to encode string into \w+ sequence. The inverse function is
# decode_w.
#
# The characters from the set {x, \W}, i.e., x or any character that
# is not a letter, digit, or _ is replaced with xXX, where XX are
# hexadecimal digits of its code number.
sub encode_w {
local $_ = shift;
s/[\Wx]/'x'.uc unpack("H2",$&)/ge;
return $_;
}
1;