7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
use strict;
use warnings;
my @a1 = qw(a d g v 6 z h u t f e 0 n);
my @a2 = qw(h f t u);
my $last_index = (
sort{ $a <=> $b }
grep{ my $i = $a1[$_];
grep{ $i eq $_ }@a2
}(0..scalar(@a1)-1))[-1];
print $last_index;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
use strict;
use warnings;
use List::Util qw/min max/;
use Data::Dumper;
my @a1 = qw(a d g v 6 z h u t f e 0 n);
my @a2 = qw(h f t u);
my %pos = map { $a1[$_], $_ } 0..$#a1;
#print Dumper \%pos;
my @t = map { $pos{$_} } @a2;
print min(@t) . ", " . max(@t) . "\n";
7 Einträge, 1 Seite |