P
Peng Yu
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
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