in reply to Finding unique deletion strings

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1171353 use strict; use warnings; my $have = 'A B _ B A A A'; my $remove = 'A B A'; my @left; my %left; my $pattern = $remove =~ s/ /(.*)/gr; $have =~ /^$pattern$(?{ push @left, "$`$1$2$'" })(*FAIL)/; s/ +/ /g, s/^ //, s/ $//, $left{$_}++ for @left; print for sort keys %left;

Replies are listed 'Best First'.
Re^2: Finding unique deletion strings
by astro86 (Initiate) on Sep 08, 2016 at 03:28 UTC
    That was fast and spot on! Well done and thank you!