Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Forked from kazuho/gist:1d09fdbedde0c0d8891e
Last active August 29, 2015 14:07
Show Gist options
  • Save karupanerura/bce078eba0469d044882 to your computer and use it in GitHub Desktop.
Save karupanerura/bce078eba0469d044882 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
my $re_paren;
$re_paren = qr {
\(
(?:
(?>[^\(\)]+)
| (??{ $re_paren })
)*
\)
}xs;
my $re_str = qr{"(?:\\"|[^"]*)*"};
my $src = join '', <STDIN>;
$src =~ s{
(?:(?<=[^A-Za-z0-9_])|^)
sprintf \s*
\( \s*
" ( (?:\\"|[^"]*)* ) "
(?: \s* , \s* ($re_paren|[^,]*) )*
\)
}{ print "yeah!:$1,$2,$3" }gxs;
print $src;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment