Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trapd00r/with

Execute Perl code on files matching pattern
https://github.com/trapd00r/with

Last synced: 3 days ago
JSON representation

Execute Perl code on files matching pattern

Awesome Lists containing this project

README

        

=pod

=head1 NAME

with - execute Perl code on files matching pattern

=head1 SYNOPSIS

with -pattern PATTERN -do CODE FILES

=head1 DESCRIPTION

B 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 C block.

sub {
use strict 'refs';
BEGIN {
$^H{'feature_say'} = q(1);
}
foreach $_ (@_) {
# YOUR CODE INJECTED HERE
}
}

Note that C is imported for convience.

The C<--depth> flag controls how many directories we'll descend into. The
default is infinite.

=head1 OPTIONS

-do, --do execute 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

=head1 EXAMPLES

Find all music videos by Laleh, in 720p and mkv format. Print the results with
LS_COLORS attributes (Need L).

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 $_'

=head1 AUTHOR

Magnus Woldrich
CPAN ID: WOLDRICH
[email protected]
http://japh.se

=head1 CONTRIBUTORS

None required yet.

=head1 COPYRIGHT

Copyright 2011 the B L and L as listed above.

=head1 LICENSE

This program is free software; you may redistribute it and/or modify it under
the same terms as Perl itself.

=cut