I
ioneabu
Sorry if the formatting gets messed up. I am not on my own computer
now and Google is the only way I can post this from here. Try this
out:
#!/usr/bin/perl
use warnings;
use strict;
my @a = ('a','b','c');
my @b = ('1','2','3','4','5');
my $c = 1;
my $d = multimod('print for @a for @b if $c');
eval $d;
print "\n$d\n";
sub multimod
{
my $mods = "if|for|while|unless";
my $a = shift;
my ($b,$c,$d);
while ($a =~ /^(.*?)($mods)(.*?)($mods)(.*)/)
{
$c = $d = '';
if ($4 and $5)
{
$a = "$4$5";
$c = $4;
$d = $5;
}
if ($1) {$b = "$2($3) {$1}"}
else {$b = "$2($3) {$b}"}
}
return "$c($d) {$b}" if $c and $d;
}
now and Google is the only way I can post this from here. Try this
out:
#!/usr/bin/perl
use warnings;
use strict;
my @a = ('a','b','c');
my @b = ('1','2','3','4','5');
my $c = 1;
my $d = multimod('print for @a for @b if $c');
eval $d;
print "\n$d\n";
sub multimod
{
my $mods = "if|for|while|unless";
my $a = shift;
my ($b,$c,$d);
while ($a =~ /^(.*?)($mods)(.*?)($mods)(.*)/)
{
$c = $d = '';
if ($4 and $5)
{
$a = "$4$5";
$c = $4;
$d = $5;
}
if ($1) {$b = "$2($3) {$1}"}
else {$b = "$2($3) {$b}"}
}
return "$c($d) {$b}" if $c and $d;
}