NAME
with - execute Perl code on files matching pattern
SYNOPSIS
with -pattern PATTERN -do CODE FILES
DESCRIPTION
with takes a PATTERN, possibly a regular expression, a PATH and a piece of Perl code that'll be executed on every matching file in turn.
The Perl code will be injected in a for(@_) { ... }
block.
sub {
use strict 'refs';
BEGIN {
$^H{'feature_say'} = q(1);
}
foreach $_ (@_) {
# YOUR CODE INJECTED HERE
}
}
Note that say()
is imported for convience.
The --depth
flag controls how many directories we'll descend into. The default is infinite.
OPTIONS
-do, --do execute <code> for every file
-p, --pattern match files with pattern
-mp, --mplayer play with mplayer
-de, --depth descend at most n levels of directories
-h, --help show the help and exit
-v, --version show version info and exit
-m, --man show the documentation and exit
EXAMPLES
Find all music videos by Laleh, in 720p and mkv format. Print the results with LS_COLORS attributes (Need File::LsColor).
with -pattern 'laleh.*720.*\.mkv$' -do 'say ls_color($_)' $HOME/Mvids
Find all persistent undo files vim has created and remove them.
with -pattern '\.un~$' -do 'print "$_ deleted\n" if unlink $_'
AUTHOR
Magnus Woldrich
CPAN ID: WOLDRICH
[email protected]
http://japh.se
CONTRIBUTORS
None required yet.
COPYRIGHT
Copyright 2011 the with "AUTHOR" and "CONTRIBUTORS" as listed above.
LICENSE
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.