in reply to How to use File::Set module
use warnings; use strict; use Fatal qw/ open close /; use File::Set; sub cback { my ($context, $prefix, $fpath, $ftype, $stat) = @_; if ($ftype eq 'f') { open my $fh, '<', $fpath; my $first_line = <$fh>; print $first_line; } } my $fs = File::Set->new(); $fs->add('/some/dir'); $fs->list('',\&cback);
prints the first line of every plain file in /some/dir and all its subdirs.
A callback is a reference to a subroutine; the important parameter passed to it is the third — full path to file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to use File::Set module
by smist (Acolyte) on May 02, 2007 at 18:43 UTC |