Created
August 2, 2017 03:11
-
-
Save johannes-riecken/a28cb275f3209478253939decf9c2e31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.10; | |
use warnings; | |
use Data::Dumper; | |
my %h; | |
sub wrap { | |
my ($str, $re,$replace) = @_; | |
unless (%h) { | |
END {say Dumper %h} | |
} | |
$h{$re} += $str =~ s/$re/$replace/; | |
return $str; | |
} | |
my @lines = qw(foo bar baz); | |
for (@lines) { | |
$_ = wrap($_, qr{foo}, 'lorem'); | |
$_ = wrap($_, qr{bazzz}, 'ipsum'); | |
} | |
say Dumper @lines; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment