Perl Programming/Keywords/unpack

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: unlink Keywords Next: unshift

The unpack keyword[edit | edit source]

unpack does the opposite of pack by taking a string and expanding it out into a list of values. (In scalar context, only the first value produced is returned.)

Syntax[edit | edit source]

  unpack TEMPLATE

Example[edit | edit source]

my($what, $where, $howmuch) = @_;
unpack("x$where a$howmuch", $what);

See also[edit | edit source]

Previous: unlink Keywords Next: unshift