#!/usr/local/bin/perl $_ = <> until /^begin/; while (<>) { last if /^end/; print unpack('u', $_); }