in reply to Re^3: Challenge: Transforming markups
in thread Challenge: Transforming markups
If you just don't like referring to the global %-, maybe something like:
s/$regex/transform(%-)/ge sub transform { my %matches = @_; ... }
Or you can do a second match.
s/($regex)/transform($1)/ge sub transform { local $_ = shift; if (/^(\[\[($http)]\[($title)]])/) { return transform_named($2,$3) +} elsif (/^($http)/) { return transform_http($1) } ... }
Or you might use something like this.
while (1) { if (/\G($named)/gc) { print transform_named($1) } elsif (/\G($http)/gc) { print transform_http($1) } ... elsif (/\G(.)/gcs) { print $1 } else { last } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Challenge: Transforming markups
by LanX (Saint) on Dec 07, 2013 at 16:43 UTC |