Imitating the Unix/Linux grep command in Perl
- grep
#!/usr/bin/perl
use strict;
use warnings;
my $regex = shift;
print grep { $_ =~ /$regex/ } <>;
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
#!/usr/bin/perl
use strict;
use warnings;
my $regex = shift;
print grep { $_ =~ /$regex/ } <>;