# This is the version that is most downwards compatible but doesn't handle
# parentheses in default assignments
sub transform_arguments {
# This should also support
# sub foo($x,$y,@) { ... }, throwing away additional arguments
# Named or anonymous subs
no warnings 'uninitialized';
s{\bsub(\s*)(\w*)(\s*)\((\s*)((?:[^)]*?\@?))(\s*)\)(\s*)\{}{
parse_argument_list("$2","$5","$1$3$4$6$7")
}mge;
$_
}
####
sub fail58( $time = localtime() ) {
####
sub transform_arguments {
# We also want to handle arbitrarily deeply nested balanced parentheses here
no warnings 'uninitialized';
s{\bsub(\s*) #1
(\w*) #2
(\s*) #3
\(
(\s*) #4
( #5
( #6
(?:
\\. # regex escapes and references
|
\(
(?6)? # recurse for parentheses
\)
|
\{
(?6)? # recurse for curly brackets
\}
|
(?>[^\\\(\)\{\}]+) # other stuff
)+
)*
\@? # optional slurpy discard argument at the end
)
(\s*)\)
(\s*)\{}{
parse_argument_list("$2","$5","$1$3$4$8$9")
}mgex;
$_
}