Jeffrey Ross <> wrote:
> I can convert "414243" to "ABC" using awk
Did you know that one of the programs that comes with the perl
distribution is an awk-to-perl converter?
man a2p
(but the Perl version is as horrid as the awk version)
> a simpler way of doing it in Perl.
> perl -e 'printf "%c", hex("41")' # works for a single
> hard-coded 2-character string
>
> How do I do it for lines
"lines"?
What "lines"?
> of arbitrary length?
You must have meant "strings" instead of "lines", yes?
Assuming that $_ contains the string:
print chr hex for /(..)/g;
or
print map chr hex, /(..)/g;
or
print chr hex for split /(..)/;
or
print map chr hex, split /(..)/;
[snip awk code, we don't want that here where some innocent kid
might see it...]
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas