my $TEMPLATE = '@8A6'; # oops, originally posted without the quotes while () { my @fields = unpack $TEMPLATE, $_; # for output try pack or printf }