The grep function evaluates the expression (EXPR) for each element of the array (LIST).
Format: grep(EXPR,LIST)
# Searching for patterns in a list
@list = (tomatoes, tomorrow, potatoes, phantom, Tommy);
$count = grep( /tom/i, @list);
@items= grep( /tom/i, @list);
print "Found items: @items\nNumber found: $count\n";
Related examples in the same category