If the index difference of two consecutive elements of the array is 1 take the 1st colum of all the array i.e $sample->[0] .. $sample->[-1] PLUS the 2nd column of the last element of the array $sample->[-1].Let me give you the illustration of how I get the result. Basically those enclosed with bar (|) and dash (_) are the one which get selected. Notice also the index difference change.
I hope it's clear to you nowmy $sample1 |str1 |index = 1 |str3 |index = 2 |str5 |index = 3 |str7 |index = 4 | |_______________ |str9 str10 index = 5 |______________________ my $sample2 |str1 str2 | index = 0 |_________ | |str3 str4 | index = 4' |__________| my $sample3 |str1 | index = 3 | |_________ |str3 str4 index = 4 ____________________ my $sample4 = |str1 | index = 1 |str3 | index = 2 |str5 | index = 3 | |______________ |str7 str8 index = 4 ____________________ |str7 str8 | index = 4 |__________| |str9 str10| index = 6 ___________
In reply to Re^2: Simple Logic Problem with Perl
by Anonymous Monk
in thread Simple Logic Problem with Perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |