Ben Crane wrote:
> 
> I have a dummy list:
> 
> Dog, A, B, C
> Dog, 1, 2, 3
> Cat, A, 2, 3
> 
> I have a unique list of the first record, Dog and
> Cat...I want to look through the unique list, and then

You should probably be using a hash instead of an array for the unique list.


> match all the records from the main list (as
> above)-matching the unique list value (Dog/Cat) with
> the main list...then if there are duplicate matches,
> as above, fill the array will the info...
> 
> e.g. Dog array will contain A,B,C,1,2,3 and Cat will
> contain A,2,3...the following subroutine isn't
> working...I know the list will be x cols wide, so I
> can parse the final array quite easily...I'm dumping
> the values into a hash with the unique list name as
> the key...so I can take each key...and have the array
> as it's data...then parse it...why doesn't the
> following code work???


You probably want something like this:

my %uniqueroadname = ( Dog => 1, Cat => 1 );

my %hasharray;
while ( <DATA> ) {
    my ( $arb, @contents ) = split /\s*,\s*/;
    push @{$hasharray{$arb}}, @contents if exists $uniqueroadname{$arb};
    }

__DATA__
Dog, A, B, C
Dog, 1, 2, 3
Cat, A, 2, 3





John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to