Charlie Anderson wrote:

> Here is the complete (test) script, its part of a larger script, but this
> one fails all by itself.
> 
> $fileDir = shift @ARGV;
> # $myvar = "srctree.txt";
> print "opening file $fileDir\n";
>   open (tablehandle, $fileDir) || ($errorcheck2 = "TRUE");
>    if ($errorcheck2 eq "TRUE")
>     {
>      print mainlog "ERROR \- data table $table$data_ext missing for
> validation\n";
>      $error_flag = "TRUE";
>     }
>    $filerowcount = 0;
>    binmode tablehande;
>    while (<tablehandle>)
> #  until (eof (tablehandle)==1)
>     {
>     $tableline = $_;
>  #  $tableline = <tablehandle>;
>       $filerowcount ++;
>     print "$tableline\n";
>      print "current count = $filerowcount\n";
> }
> close (tablehandle);
> print "total count $filerowcount\n";

This is not a complete program and doesn't compile.  When you
post a snippet to this group, 1) put a use strict and -w (or use
warnings) at the top.  2) run the script as you will be posting
it to make sure it fails as described.

Here's my altered version which runs fine (I inserted a ^Z into
the middle of your data using VIM for testing).  It produced an
additional line of output:

current count = 12
?

current count = 13

use strict;
my $fileDir = shift @ARGV || 'data/foo.txt';

print "opening file $fileDir\n";
my $errorcheck2;
my $error_flag;
open TH, $fileDir or $errorcheck2 = "TRUE";
if ($errorcheck2 eq "TRUE") {
        print "ERROR - data table $fileDir missing for validation\n";
        $error_flag = "TRUE";
}
my $filerowcount = 0;
binmode TH;
while (<TH>) {
        my $tableline = $_;
        $filerowcount++;
        print "$tableline\n";
        print "current count = $filerowcount\n";
}
close TH;

print "total count $filerowcount\n";

__END__


> Also,
> 
> Here is part of the file to be processed.
> 
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99404Cumultv EOC in Actg Principle Cumultv EORT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99405Purchase Accounting Adj.      Purchase ART_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99406Interacct Transfers (reclassesInteracct RT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99407Intercompany Transfers        IntercompaRT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99408Add'tInvestment Expenditures  Add'tInveRT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99409Add'tInc's in Resv/Accrl Exp. Add'tInc'RT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99411Add'tOth Bal Sheet Chn'g      Add'tOth RT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99412Add't-Capital Expenditures    Add't-CapiRT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5
> DUKENRESOURCE_TYPE     01/01/1940ACCOUNTING          ROLLFORWARD_RPTG
> 99413Add't-Increase in Debt        Add't-IncrRT_GROUPS Accounting
> RT_DETAILSRoll Forward Reporting                  4          5


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to