Prev: FAQ 9.2 My CGI script runs from the command line but not the browser. (500 Server Error)
Next: count the number of element in an array that are greater than some values?
From: Peng Yu on 18 Jun 2010 21:50 I'm wondering what is the shortest code to count the number of element in an array that are greater than some values. I'm just not familiar with perl enough to know what is the best way. A for-loop is the easiest way to think of. I also come up with the following way. But I'm not sure how to simply it in one line. I'm sure that there are better ways. Would you please let me know so that I can understand the expressive power of perl? @new_array=grep { $_ > 5 } @array; $#new_array+1 |