use strict; use warnings; use Getopts::Std; #Global Variables my $in_file = $ARGV[0]; my $encoding = ":encoding(UTF-8)"; #Check file to see what type of file you are looking at. sub check_file { my $head = system head => -1 => $in_file; # Grab header/first line of file print $head; if ( $head =~ m/^ABC/ ) { print "This is a ABC File. Processing ABC File...\n"; prcss_abc_file(); } else { if ( $head =~ m/^ISA~ / ) { print "This is an EDI File. Processing EDI File...\n"; prcss_edi_file(); } else { print "This is not a file! Attempting to process BTN...\n"; prcss_btn(); } } } check_file();