PDA

View Full Version : Help out a newbie


kiwipenguin
12-23-2002, 11:27 PM
Hi all

I've just started out learning Perl, found it was pretty tricky for a complete novice, so switched to Python. Now that I actually have some idea what I'm doing I'm tackling Perl again.

I saw this as someone's sig one a board, and would love for someone to explain to me exactly how it works.


perl -e 'print pack"H*","64776f6c6c6d616e6e407075747479626f782e636f6d0a"'



Thanks in advance

Danger Fan
12-24-2002, 01:47 AM
basically, when you specify the '-e' parameter, you put a line of code after it. Then the interpeter executes that one line of code. I don't know what all the 'pack"H*"' stuff is, but theoretically, it just prints all that stuff out.

nex
12-24-2002, 07:39 AM
http://www.perldoc.com/perl5.8.0/pod/func/pack.html

pack TEMPLATE,LIST

Takes an array or list of values and packs it into a binary structure,
returning the string containing the structure. The TEMPLATE is a
sequence of characters that give the order and type of values, as
follows:

(snip)
H A hex string (high nybble first).



"64776f6c6c6d616e6e407075747479626f782e636f6d0a" is a bunch of numbers in hex (64, 77, 6F, 6C). the pack() here takes each of these and forms a string based on the ASCII values (x64 = "d", x77 = "w", etc).

The resulting string in this case is an email address.