#! /usr/bin/perl use strict; use warnings; use IO::File; use Data::Dumper; my $in_fh = $ARGV[0]; open(my $in_fh = IO::File->new, "<", $infile) or die "Can't open $infile: $!.\n"; close $in_fh; my $chunk =~ s/[\f\r\n]//g; my @statement = split '`', $chunk; chomp @statement; foreach my $line (@statement) { my @fields = split '~\d\d', $line; next unless length $line; next unless scalar(@fields); my $fieldno = shift @fields; print Dumper(@fields); }