App-pl

 view release on metacpan or  search on metacpan

pl  view on Meta::CPAN

854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
=item C<-FI</pattern/>>
 
I<perl:> Provide C<split()> pattern for B<-a> switch (C<//>'s are optional).
 
=item C<-II<directory>>
 
I<perl:> Specify C<@INC>/C<#include> directory (several B<-I>'s allowed).
 
=item C<-iI<[extension]>>
 
I<perl:> Edit C<< <> >> files in place (makes backup if extension supplied).
 
=item C<-n>
 
I<As I said before, I never repeat myself. :-)>
 
I<perl:> Assume C<< while (<>) { ... } >> loop around program.  It's a little
richer than that: if you use C<last>, it closes the current file, leaving you
to continue the loop on the next file.
 
=item C<-oI<[number]>>

t/n-loop.t  view on Meta::CPAN

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Testing -i is a bit more complicated. pl_e -i doesn't really test anything.  The actual test comes then.
my @copies = map {
    open my $in, '<', $_ or die $!;
    my $copy = "copy-$_";
    open my $out, '>', $copy or die $!;
    defined( syswrite $out, slurp $in ) or die $!;
    $copy;
} @files;
 
# Since -i outputs nothing, instead as a side effect test that I get STDERR.
pl_e "get me\nnow", '-pibkp', '-B warn "get me\n"; E "now"', 'tr/abc/xyz/', @copies;    # Windows perl requires -i with backup
 
$_ = $copy;
for my $sfx ('bkp', '') {
    test "pl -i file$sfx contents",
      join '', map {
          open my $in, '<', $_.$sfx or die $!;
          slurp $in;
      } @copies;
    tr/abc/xyz/;
}



( run in 0.460 second using v1.01-cache-2.11-cpan-cba739cd03b )