I am haing a hard time getting this subroutine to work properly. The issue I am having is that the output skips all the way to the last else statement and prints "This is not a file! Attempting to process BTN...". Apparently I am missing something in my pattern matching, but I cannot figure it out. Any help would be much appreciated.
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();
In reply to Matching patterns in condisional statements by smturner1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |