App-pltest
view release on metacpan or search on metacpan
pod/examples.pod view on Meta::CPAN
pltest -n 'if( /^\s*package\s+([^\s;]+)/ ) {
$d = $1 =~ tr+.+/+r;
} elsif( /^\s*(?:(?:public|private|protected|abstract|sealed|final)\s+)*(?:class|interface|enum|record)\s+([^\s;]+)/ ) {
rename $ARGV, "$d/$1.java" or warn "$ARGV -> $d/$1.java: $!\n";
last;
}' *.java
=item Delete Matching Files, Except Last One
If you have many files, which sort chronologically by name, and you want to
keep only the last one, it can be quite painful to formulate Shell patterns.
So check on each iteration of the B<-o> loop, if the index C<$ARGIND> (or
C<$I>) is less than the last, before unlinking (deleting). If you want to test
it first, replace C<unlink> with C<e(cho)>:
pltest -o 'unlink if $ARGIND < $#ARGV' file*
If your resulting list is too long for the Shell, let Perl do it. Beware that
the Shell has a clever ordering of files, while Perl does it purely lexically!
In the B<-A> code the result is assigned to C<@A(RGV)>, as though it had come
from the command line. This list is then popped (shortened) in B<-B> begin
( run in 0.560 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )