Advertisement

03.25.2008 at 08:06AM PDT, ID: 23267222
[x]
Attachment Details

Check a file for multiple  headers

Asked by MatthewF in Perl Programming Language

I have a sctipt that check either the last line starts with either TOT or TR . It check that there is date between the first and last line.  It also check if the first line start with HD.  However, when tried a or statemnet ot check if the first line starts with HD or BAL i always get the output, invlaid header.


#!/usr/bin/perl
$file."DUP.txt";

$bad_header="invalid header";
$bad_trailer="invalid trailer";
$bad_data="no vaild context";

open IN, "$file" || die "Can't open $file $!\n";
if ((-z $file)|| (!-e $file)){
       push(@output, $bem_text);
        }

my $middle = 0;
while( <IN> ){
    if( eof ){
       ##first is check of data between first and last lines
        push(@output, "$bad_data " )unless $middle;
      ##Check Trailer
       push(@output, "$bad_trailer ") unless /^TOT/ || /^TR/;
               }  
    elsif( 2..eof ){
        $middle += /\S/;
                    }
    ##Check HEADER
     push(@output, "$bad_header") if 1..1 and  !/^HD/ || !/^BAL/;
         }

 print "the output is @output";Start Free Trial
[+][-]03.25.2008 at 09:07AM PDT, ID: 21203209

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 09:27AM PDT, ID: 21203424

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Sign Up Now!
Solution Provided By: FishMonger
Participating Experts: 3
Solution Grade: A
 
 
[+][-]03.25.2008 at 09:31AM PDT, ID: 21203466

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 10:15AM PDT, ID: 21203914

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 10:29AM PDT, ID: 21204046

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.25.2008 at 10:30AM PDT, ID: 21204060

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 10:32AM PDT, ID: 21204079

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 11:16AM PDT, ID: 21204510

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628