in reply to Using vec to search an array
vec EXPR,OFFSET,BITS Treats the string in EXPR as a bit vector made up of elements +of width BITS, and returns the value of the element specified by OFFSET as an unsigned integer.
You're doing nasty stuff with references to variable names, which would flail with use warnings so you code like this at your own peril.
First, line 16, change from
tofor (@{$domains[$i]}) { vec($scratch,$_,1) = 1}
for (@{$domains[$i]}) { vec($$scratch,$_,1) = 1}
Next, the ending for loop, should written as follows:
Note the second for loop, and the use of the scratch variable.for ( $j = 0; $j <= 5; $j++ ) { my $scratch = "domains$j"; for ( $i = -100 ; $i <= 2000 ; $i++ ) { if (vec($$scratch,$i,1)){ print "\t $i recognised as part of the 1st domain using the ne +w method\n"; } } }
I would never personally code like this, but hopefully it is of some assistance to you.
Update: fixed a mis typed code tag.
|
|---|