dynamic_config => 0,
license => 'perl',
requires => {
- 'perl' => '5.006', # probably, only 5.8+ tested
+ 'perl' => '5.010',
'autodie' => 0,
},
build_requires => {
Source: libfile-rewrite-perl
Section: perl
Priority: optional
+Depends: perl (>= 5.10.0)
Build-Depends: debhelper (>= 7), perl (>= 5.6) | libmodule-build-perl
-Build-Depends-Indep: perl (>= 5.6.1), libtest-nowarnings-perl
+Build-Depends-Indep: perl (>= 5.10.0), libtest-nowarnings-perl
Maintainer: Mischa POSLAWSKY <perl@shiar.org>
Standards-Version: 3.8.3
Homepage: http://search.cpan.org/dist/File-Rewrite/
use strict;
use warnings;
+use 5.010; # smart match
use autodie ':all';
use Exporter 'import';
$replace = $search if @_ < 3;
- # generate a single regex to emulate smart match
- $search = [$search] unless ref $search eq 'ARRAY';
- @$search = grep { defined } @$search;
- $search = @$search ? join('|', map { ref $_ ? $_ : "^\Q$_\E\$" } @$search) : undef;
-
open my $src, '<', $filename;
open my $dest, '>', $tmpname;
while (readline $src) {
chomp;
- if (defined $search and $_ =~ /$search/s) {
+ if ($_ ~~ $search) {
if (ref $replace eq 'ARRAY') {
if (@$replace and $_ eq $replace->[0]) {
shift @$replace;
testfileset('add string', "foo$/", ['bar'], 1, "foo$/bar$/");
testfileset('keep string', "foo$/bar$/", ['foo'], 0, "foo$/bar$/");
testfileset('keep first', "foo$/FOO$/foo$/", ['foo'], 1, "foo$/FOO$/");
-testfileset('replace string', "$/0$/1$/2$/", [0 => 3], 2, "$/1$/2$/3$/");
+testfileset('replace string', "$/0$/1$/2$/", ['0' => 3], 2, "$/1$/2$/3$/");
testfileset('keep regex', "foo$/hi$/$/", [qr/./ => 'hi'], 1, "hi$/$/");
testfileset('add new array', ".$/", ['' => ['foo','.']], 2, ".$/foo$/.$/");