Andrew Robert wrote:
Wanted:
> perl -ple 's/([^\w\s])/sprintf("%%%2X", ord $1)/ge' somefile.txt
Got:
> # Evaluate captured character as hex
> def ret_hex(ch):
> return chr((ord(ch) + 1) % )
Make it compile at least before posting :-)
> # Evaluate the value of whatever was matched
> def
Andrew Robert wrote:
> I have two Perl expressions
>
>
> If windows:
>
> perl -ple "s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt
>
> If posix
>
> perl -ple 's/([^\w\s])/sprintf("%%%2X", ord $1)/ge' somefile.txt
>
>
>
> The [^\w\s] is a negated expression stating that any charac
I have two Perl expressions
If windows:
perl -ple "s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt
If posix
perl -ple 's/([^\w\s])/sprintf("%%%2X", ord $1)/ge' somefile.txt
The [^\w\s] is a negated expression stating that any character
a-zA-Z0-9_, space or tab is ignored.
The ()