> -----Original Message-----
> From: Joseph Paish [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 23, 2004 9:18 AM
> To: perl_beginner
> Subject: error msg : can't use string as an ARRAY ref

<SNIP MESSAGE>

> while (<fh1>) {
>     push (@all_of_them, $_ ) ;  # an array of all the records in the file

Since you are not splitting $_, @all_of_them is a single-dimension array.

>     my @single_line = split/ /, $_;
>     push (@temp_array, $single_line[3]) ; # a list of all the
> part numbers,
> including duplicates
> }

<SNIP MESSAGE>

> foreach $temp1 (@unique_part_nbrs) {
>     for ($ctr = 0 ; $ctr < (scalar(@all_of_them)) ; $ctr++) {
>       print if ($all_of_them[$ctr][3] eq $temp1) ;

Here you are treating @all_of_them as a multi-dimensional array, and this is
where the error occurs.  Solve this by -

a) Splitting the array element here <<print if (split / /,
$all_of_them[$ctr] eq $temp1) ; >>
b) Splitting $_ when you push the data into @all_of_them << push
(@all_of_them, split / /, $_) ; >>
c) Just push the part number into @all_of_them and don't worry about
accessing a multi-dimensional array.


HTH -

Ron Goral



-- 
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