- or download this
>perl -E 'say for grep { $_%2==0 } (1..10)'
2
4
...
8
10
>
- or download this
>perl -E 'use List::Util qw( first ); say first { $_%2==0 } (1..10)'
2
>
- or download this
>perl -E 'use List::Util qw( any ); say any { $_%2==0 } (1..10)'
1
>
- or download this
>perl -E 'use List::Util qw( all ); say all { $_%2==0 } (1..10)'
>
- or download this
>perl -E 'use List::Util qw( sum ); say sum grep { $_%2==0 } (1..10)'
30
>