emx
emx

Reputation: 1313

Perl pack, unpack and STDIN

Can someone explains me why this is not working as I expect it?

zen:~ emx$ echo ABC | perl -nle "print unpack 'H*'"
414243
zen:~ emx$ echo 414243 | perl -nle "print pack 'H*'"

zen:~ emx$

Somehow I was expecting the second command to print ABC

Upvotes: 2

Views: 909

Answers (1)

lanzz
lanzz

Reputation: 43168

unpack() uses $_ by default if you do not provide it with a second parameter; pack() on the other hand, does not.

Upvotes: 5

Related Questions