Here is an application you will need:VARIABLES $_ Default variable for operators to use $` Everything prior to matched string $& Entire matched string $' Everything after to matched string $1,$2... Hold the Xth captured expr $+ Last parenthesized pattern match $^N Holds the most recently closed capture $^R Holds the result of the last (?{...}) expr @- Offsets of starts of groups. @+ Offsets of ends of groups.
Produces:use strict; use Data::Dumper; my $con = qr/[b-df-hj-np-tv-xz]/; my $vow = qr/[aeiouy]/; my $ncon = qr/[^b-df-hj-np-tv-xz]/; my $nvow = qr/[^aeiouy]/; my $x = 'battlestar galactica'; my $y = 'silly ahab'; ($x,$y) = map{swap($_)}($x,$y); print Dumper([$x,$y]); sub swap { my $x = shift; if($x =~ /(${con})(${ncon}*?\b)(${ncon}*?)(${con})/){ $x = $`.$4.$2.$3.$1.$'; } $x }
$VAR1 = [ 'battlestag ralactica', 'silhy alab' ];
In reply to Re^4: unglue words joined together by juncture rules
by mobiusinversion
in thread unglue words joined together by juncture rules
by pc2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |