#!/usr/bin/perl -w
use strict ;
use POSIX ; # i need POSIX for some calculations not shown here 

# variable declarations went here

open (fh1, "</path/to/filename") or die ("nope") ;
# sample of layout of fh1  :    03/06/1997 sold 1000 widget1 0.230 0.00       
# part number in this case is widget1; there are several dozen part numbers 
in a file of several hundred lines                                            
                  
while (<fh1>) {
    push (@all_of_them, $_ ) ;  # an array of all the records in the file
    my @single_line = split/ /, $_;
    push (@temp_array, $single_line[3]) ; # a list of all the part numbers, 
including duplicates 
}

close (fh1) ;

map {$temp_hash{$_} = 1} @temp_array ; # eliminate the duplicate part numbers 

my @unique_part_nbrs = (sort keys (%temp_hash)) ;  # sort unique part numbers 
and place in an array

# everything works well up to here !!!!!!!! 

# what i want to do is loop through the sorted unique part numbers array and 
print out all the array elements in @all_of_them that have a part number that 
matches that unique value.  i then move onto the next unique part number and 
do the same thing
 
foreach $temp1 (@unique_part_nbrs) {
    for ($ctr = 0 ; $ctr < (scalar(@all_of_them)) ; $ctr++) {
        print if ($all_of_them[$ctr][3] eq $temp1) ; 
    }
}

# error message is : "can't use string ("03/06/1997 sold 1000 widget1 0.230 
0.00") as an ARRAY ref while "strict refs" in use at line 33"

note that the line number isn't accurate here because this isn't an exact 
listing of the program.

suggestions?

thanks

joe




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to