smturner1 has asked for the wisdom of the Perl Monks concerning the following question:
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();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching patterns in condisional statements
by haukex (Archbishop) on Jul 05, 2017 at 16:16 UTC | |
|
Re: Matching patterns in condisional statements
by Eily (Monsignor) on Jul 05, 2017 at 16:14 UTC | |
by smturner1 (Sexton) on Jul 05, 2017 at 17:23 UTC | |
|
Re: Matching patterns in condisional statements
by 1nickt (Canon) on Jul 05, 2017 at 16:13 UTC | |
by smturner1 (Sexton) on Jul 05, 2017 at 17:41 UTC | |
by stevieb (Canon) on Jul 05, 2017 at 17:44 UTC | |
by Anonymous Monk on Jul 06, 2017 at 22:48 UTC |