waytoperl has asked for the wisdom of the Perl Monks concerning the following question:
trying to convert hex to ascii and was able to convert. Any idea code can be written more efficiently. Please preview.
my $x = 30:30:3a:31:64:3a:69:2d:6f; #in hex my $x =~ tr/://d; my $y = hex_to_ascii("$x"); print "$y\n"; #in ascii
Above can be achieved using one liner? Tried using pack and unpack and closest i can think of was split, conversion and pack. Preview and guide how to correct. Thanks!
my $y = pack ('C*', split/\:/, $x);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Hex ASCII pack unpack
by ikegami (Patriarch) on Sep 26, 2014 at 05:21 UTC | |
by waytoperl (Beadle) on Sep 26, 2014 at 19:23 UTC | |
|
Re: Perl Hex ASCII pack unpack
by Anonymous Monk on Sep 26, 2014 at 07:38 UTC |