How to find maximum and minimum value in an array of integers in Perl?

后端 未结 12 2075
花落未央
花落未央 2020-12-14 18:43

I have an array with values 33, 32, 8, 100.

How can I find the maximum and minimum value in this array?

Do I need to include any special libraries?<

12条回答
  •  独厮守ぢ
    2020-12-14 19:20

    Use the List::Util module, which it is recommended to get acquainted with anyway, just like List::MoreUtils:

    D:\ :: perl -MList::Util=max -lwe "print max 324, 43, 53, 3532, 43"
    3532
    
    D:\ :: perl -MList::Util=min -lwe "print min 324, 43, 53, 3532, 43"
    43
    

提交回复
热议问题