I have two subroutines that are have unexpected results. The first is passed an array ref to a list of file names. It then calls a subroutine and passes a file name to that subroutine. When that routine finishes everything in the @files that was passed to point is changed from a file name to the relevant line matched by the reg exp in the subroutine point. All the other files that where in the array are now empty.
sub processdate { my $filenames = shift; my $sql; my @date = split /\./; my @files = grep { /_\((\d+)\)_/, ($1 - 1) % 6 > 2 } @$filenames; my $date = "$date[2]-$date[0]-$date[1]"; my %salesdetail = ( date => $date ); my %pel = ( date => $date, company => 'P' ); my %cfb = ( date => $date, company => 'C' ); foreach ( @files ){ if ( /_\((\d+)\)_/ ) { print "$_\n"; $salesdetail{ point } += point( \$_ ) if ( ($1 - 1) % 6 == 4 ); # Point Sales print "$_\n"; salesdetail( $_, \%salesdetail ) if ( ($1 - 1) % 6 == 5 ); # Sales Break Down salessum ( $_, \%pel, \%cfb, \%salesdetail ) if ( ($1 - 1) % 6 == 3 ); # Sales Information - Totals } } die; $sql = 'INSERT into sales_detail '; insertdata( $sql, [\%salesdetail] ); $sql = 'INSERT into sales'; insertdata( $sql, [\%pel,\%cfb] ); #add code to zip files and } sub point { my $filename = shift; open ( IN, "<$$filename" ) or die "Could not open file $filename $!\n"; while ( <IN> ) { return formatnum( $1, $2 ) if ( /Point Health Centers\s+((?:\d+,)?(?:\d+\.)?\d+)(-?)/ ); } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]