Here's a fun little hole: Write a function that runs under
use strict; which returns a list of the files in the current directory that contain a certain pattern. The pattern to match is passed to the function. Here's an example usage:
use strict;
sub filegrep {
...
}
my @files = filegrep('Match this!');
My best is 56:
sub filegrep {
# 1 2 3 4 5
#12345678901234567890123456789012345678901234567890123456
my@k;for(<*>){open F,$_;push@k,$_ if grep/$_[0]/,<F>};@k
}
How many strokes can you shave?
kelan
Yak it up with Fullscreen ChatterBox