In Perl, how can I find the index of a given value in an array?

前端 未结 7 1700
迷失自我
迷失自我 2020-12-01 11:15
$VAR1 = [
          \'830974\',
          \'722065\',
          \'722046\',
          \'716963\'
        ];

How can I calculate the array index for

相关标签:
7条回答
  • 2020-12-01 12:04
    use strict;
    use Data::Dumper;
    
    sub invert
    {
     my $i=0;
     map { $i++ => $_ } @_;
    }
    
    my @a = ('a','b','c','d','e');
    
    print Dumper @a;
    
    print Dumper invert @a;
    
    0 讨论(0)
提交回复
热议问题