Hello.
Am looking for some opinions on how to write these operations.
@array1A=qw(a b c d); @array1B=qw(p z e t i u); @array_of_arrays=(@array1A, @array1B, @array2A,@array2B…@arrayNA,@arra +yNB);
sub arrays have different lengths have unique values and don't want to sort them. I want so sort the array_of_arrays based on following
1. sort array based on number of elements in each from smallest to largest
2. is it possible to sort the sub-arrays by name? then size?
3. to do a random sort by name with (1A,2A…) then (1B,2B,…). Example
@array_of_arrays=(@array2A,@array4A,@array1A,…@array1B,@array5B);the interesting part is the operations on the sub arrays, I do search of each sub array with a scalar value. the following loop has no sorting .
while (<DATA>){ chomp; my @element = split; my $i1=shift @element; my $i2=shift @element; my $i3=shift @element; my $i4=shift @element; shift @element; shift @element; my $i7=shift @element; if(any{ $_ eq $i1} @array1A)) {print 'yes'; }elsif((any{ $_ eq $i1} @array1B)) {print 'no'; }elsif((any{ $_ eq $i2} @array2A)) {print 'yes'; }elsif((any{ $_ eq $i2} @array2B)) {print 'no'; }else{print "WTF";} };
I need the If loop rearranged based on the order of the array_of_arrays Is this possible?
All help is appreciated.
In reply to multiple array processing by f77coder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |