Imitating the Unix/Linux grep command in Perl



examples/advanced-perl/unix_grep.pl
#!/usr/bin/perl
use strict;
use warnings;

my $regex = shift;
print grep { $_ =~ /$regex/ } <>;