# assume the current line is in $_ my $foo = substr $_, 5, 40; # or else my ($foo) = unpack "x5 A46", $_;