I'm having problem getting multiple values returned from a subroutine.
Thanks in advance for pointers.

My codes:

#!/usr/bin/perl
use strict;
use warnings;

############################################################################
# Get required subroutines which need to be included.                      #
############################################################################
require "/home/sybase/scripts/pl/prod/global_dcapdsg001.pl";
require "/home/sybase/scripts/pl/prod/dataStage_dcapdsg001.pl";
my $po_file = '/ftpsite/as400/ms4/SH135.prt';
#############################################################################
#       MAIN
#############################################################################
my ($company_header, $company_name, $period, $GLYear) = parse_title();
print "$company_header, $company_name, $period, $GLYear\n";

if ($company_header !~ /^\d{3}$/ or $GLYear !~ /^\d{4}$/ or  $period !~ 
/^\d{1,2}$/ ){
   die " comany or year or month does not look right\n" ;
}
#parse_report();
#insert_raw_to_prod();
#if ($Lawson_company eq '213'){ create_DELTA_after_load_ABSMC(); }

#############################################################################
#  SUB ROUTINE
#############################################################################


sub parse_title{
   # Determine what company, month, and  year to load by parsing the report 
title

   open IN, '<', $po_file or die "cannot open $po_file because $!\n";
   my $found_C =   0;
   my $found_P =   0;

   while (my $line = <IN>) {
     chomp;
     if ($line =~ /^\*.*Company:.*\*$/){
     #DataSample: *    Company:  205   EDEN MEDICAL CENTER *
       print "Line: $line \n";
       my $company_header = substr($line,32,3);
       my $company_name = substr($line,38,35);
       print "Company: $company_header\nCompany Name: $company_name\n";
       $found_C= 1 ;
     }
    if ($line =~ /^.*Inventory Items As Of Cutoff Period.*\d\d\d\d$/){
     #Data Sample:  Inventory Items As Of Cutoff Period 12  December 31, 2010
       print "Line: $line\n";
       my $period = substr($line,77,2);
       print "Period: $period \n";
       my $GLYear = substr($line,-5,4);
       print "GLYear: $GLYear \n";
       $found_P = 1;
    }
    #If found both company and period, no need to scan the rest of the file.
    last if ($found_C == 1 and $found_P == 1);

   }#end while
   close IN;
   #return($company_header, $company_name, $period, $GLYear);
   return("$company_header", "$company_name", "$period", "$GLYear");
} #end sub

__END__

The problem is :
I expect to see: 361, WEST BAY SERVICE CENTER, 12, 2010 from the print 
statement above but only get , , , intead. What is wrong with my codes? 

=below is a data sample


*                     Company:  361   SUTTER WEST BAY SERVICE CENTER            
    *
*                                                                               
    *
*               Update Option: Y       Run in Update                            
    *
*           GL Posting Period: 12      Period 12                                
    *
*             GL Posting Year: C       Current GL Year                          
    *
*         Detail Transactions: Y       Detail Transactions                      
    *
*                                                                               
    *
*                                                                               
    *
*                                                                               
    *
*************************************************************************************
^M^LSH135 Date 01/03/11                                Company   361 - SUTTER 
WEST BAY SERVICE CENTER   Page    1
      Time 11:24                                   Received Not Invoiced 
Liability Report          (Update)
                                         Inventory Items As Of Cutoff Period 12 
 December 31, 2010
                                                         * Indicates Line Total

Process Level: 10    WEST BAY DISTRIBUTION CENTER

          PO Number                                Received Not                 
           PO Currency              Base Curre
ncy
Purch Fr  Received Date               Line         Invoiced Qty             
Unit Cost      Extended Amount Curr     Extended A
mount
--------- ------------------------- ------ --------------------- 
--------------------- --- --------------- -----  ------------
-----

                   69149-0000            1               12.0000               
15.3496              184.20 USD              18
4.20
D3A  10/27/10  361 551000         - 10810-                           131601     
                      LBL MED ADDED TO IV
Vendor:      321 MOORE WALLACE NORTH AMER INC    Buyer:C25  HARRY BRADLEY



                   70595-0000            1               12.0000               
15.3496              184.20 USD              18
4.20
D3A  12/17/10  361 551000         - 10810-                           131601     
                      LBL MED ADDED TO IV
Vendor:      321 MOORE WALLACE NORTH AMER INC    Buyer:C25  HARRY BRADLEY


=end


      

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to