Looping through an array of hashes in Perl

前端 未结 1 2010
忘掉有多难
忘掉有多难 2020-12-19 03:48

I\'m a total Perl newbie, so forgive me if this is really stupid, but I can\'t figure this out. If I have an array like this:

my @array = (
  {username => \'         


        
相关标签:
1条回答
  • 2020-12-19 04:22

    @array contains hash references, so you need to use -> to derefecence.

    print "$_->{username} : $_->{email}\n" foreach (@array);
    

    See also the documentation, for instance perldoc perlreftut and perldoc perlref.

    0 讨论(0)
提交回复
热议问题