Help for this page

Select Code to Download


  1. or download this
    my @match = do {
        open my $fh, '<', $file or die "$!";
        grep /^$ARGV[0]\|/, <$fh>;
    };
    
  2. or download this
    my @match;
    {
    ...
        my $rx = qr/^$ARGV[0]\|/
        m/$rx/ && push @match, $_ while <$fh>;
    }
    
  3. or download this
    sub grep_file {
        my ($rx, $file) = @_;
    ...
    };
    
    my @match = grep_file($ARGV[0], $file);