F
fhscobey
Hi,
Just curious if anyone knows why the following happens:
Example 1:
$ perl -e 'print("\x{4A}\x{65}\x{66}\x{66}","\n");'
Jeff
Example 2:
$ echo '\x{4A}\x{65}\x{66}\x{66}' | perl -e
'while(<STDIN>){print("$_");}'
\x{4A}\x{65}\x{66}\x{66}
Example 3:
$ echo '\x{4A}\x{65}\x{66}\x{66}' | perl -e 'while(<STDIN>){$line="$_";
chomp($line); @chars=split(//,"$line"); foreach $ch
(@chars){print($ch,"|");}}'
\|x|{|4|A|}|\|x|{|6|5|}|\|x|{|6|6|}|\|x|{|6|6|}|
Not sure why Perl doesn't recognize the string in Ex. 2 as a hex
string. Anyone know why? Also, how would one iterate over the
individual chars of the hex string in Ex. 3? I'm assuming the answer
to #2 has something to do with #3.
I'm using RedHat Linux 7.2, perl 5.8.1.
Thanks for any assistance you can offer!
- Jeff
Just curious if anyone knows why the following happens:
Example 1:
$ perl -e 'print("\x{4A}\x{65}\x{66}\x{66}","\n");'
Jeff
Example 2:
$ echo '\x{4A}\x{65}\x{66}\x{66}' | perl -e
'while(<STDIN>){print("$_");}'
\x{4A}\x{65}\x{66}\x{66}
Example 3:
$ echo '\x{4A}\x{65}\x{66}\x{66}' | perl -e 'while(<STDIN>){$line="$_";
chomp($line); @chars=split(//,"$line"); foreach $ch
(@chars){print($ch,"|");}}'
\|x|{|4|A|}|\|x|{|6|5|}|\|x|{|6|6|}|\|x|{|6|6|}|
Not sure why Perl doesn't recognize the string in Ex. 2 as a hex
string. Anyone know why? Also, how would one iterate over the
individual chars of the hex string in Ex. 3? I'm assuming the answer
to #2 has something to do with #3.
I'm using RedHat Linux 7.2, perl 5.8.1.
Thanks for any assistance you can offer!
- Jeff