#!perl -l
$_.=($d=$ARGV[$|--])x(/./g,$d)[$f++]until/.{$ARGV[2]}/;print$&
|
#!perl -l
$c=pop;$_.=($d=$ARGV[$|--])x(/./g,$d)[$f++]until/.{$c}/;print$&
|
somewhat better :-)
#!perl -l $c='.'x pop;$_.=($d=$ARGV[$f%2])x(/./g,$d)[$f++]until/$c/;print$& |
#!perl -l $c='.'x pop;$d=$ARGV[$f%2],$_.=$d x((/./g)[$f++]||$d)until/$c/;print$& |
attempt #2 : slightly better
#!perl -l $c='.'x pop;$d=$ARGV[$f%2],$_.=$d x(substr($_,$f++,1)||$d)until/$c/;print$& |
first shot
#!perl -l ($n,$d)=@ARGV;$l='.'x pop;$_.=$n x(/$c(.)/?$1:$n),$c.='.',($d,$n)=($n,$d)until/$l/;print$&; |