Copyright © tutorialspoint.com
grep EXPR, LIST
grep ( EXPR, LIST) extract any elements from LIST for which EXPR is TRUE.
In scalar context - Number of times the expression returned true
In list context - List of elements that matched the expression
Try out following example:
#!/usr/bin/perl @list = (1,"Test", 0, "foo", 20 ); @has_digit = grep ( /\d/, @list ); print "@has_digit\n"; It produces following result 1 0 20