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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.