#!/usr/bin/perl -w #By Ørjan Johansen, June 2009-Jan 2012. This file is in the public domain. my $debug = ($#ARGV >= 0 and $ARGV[0] =~ m/^-d([1-2]?)$/ and shift and ($1 || 2)); $| = 1; $_ = join '', <>; while (1) { print "\n[", $_, "]" if $debug >= 2; if (s!^GG((?:[^/\\]|\\.)*?)GG!!s) { my $s = $1; $s =~ s/\\(.)/$1/gs; $d = getc(); no warnings; while (s/(?:\Q$s\E)/$d/) { } } elsif (s!^([^/\\][^/\\G]*)!! or s!^\\(.)!!s) { print($1); print "\n[", $_, "]" if $debug == 1; } elsif (s!^/((?:[^/\\]|\\.)*)/((?:[^/\\]|\\.)*)/!!s) { my ($s,$d) = ($1,$2); $s =~ s/\\(.)/$1/gs; $d =~ s/\\(.)/$1/gs; while (s/(?:\Q$s\E)/$d/) { } } else { last; } }