Pergunta de entrevista da empresa Booking.com

Perl's grep and map function

Resposta da entrevista

Sigiloso

5 de jul. de 2015

grep is a filter, and returns the original list item if the expression test was true ex : my @arr = grep { $_ > 2; } (1, 2, 3); #@arr ==> (3) map : return the expression from map block to a new array ex : my @arr = map { $_ > 2; } (1, 2, 3); #@arr ==> ('','',1);