# Look ahead into the file for the ISA segment and the few characters which # follow it, so that we can determine the segment terminator character(s). $/ = \108; my $ISA_and_trailing_chars = <>; # examine the text after the segment for the segment termination character(s) $ISA_and_trailing_chars =~ / ^.{105} # The actual ISA segment, itself ( .? # The proper segment terminator character \r? # If the segment terminator is followed by a newline and/or \n? # carriage return, include that as part of the segment # terminator. this isn't really legal to do, but some # folks do it, regardless, and we want to be able to handle # that sort of garbage as though it weren't garbage. ) /x; my $segment_terminator = $1; # set the input record separator to the segment termination character(s), so # that subsequent reads from the file will read one segment at a time. $/ = $segment_terminator; # since we peeked ahead into the file, to determine *how* to read it, now # seek back to the beginning of it, so that we can read it (all) correctly seek ARGV, 0, 0;