简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM