in reply to Re: How do I get an exclusion with grep?
in thread How do I get an exclusion with grep?
The only thing I left out of the big block of code with the crossover_magic is the "heading" of the module. So, here is the contents of @cross_files and the results of textify on them side-by-side. textify is at the bottom of this post. Also, if you need any other subroutines, let me know.
| @cross_files | textified |
|---|---|
|
|
I am using this in scripts, so no -- options. Here is how crossover_magic is being used in the scripts.
my $magic = crossover_magic(); # no big svgs here, s +o no $opt{big} # The rest have only one that should NOT have ' right' appended to $cl +ass my $magic = crossover_magic( big => ['Horror']); my $magic = crossover_magic( big => ['Westerns in Crisis']); # I'd lik +e to use the word 'Westerns' only my $magic = crossover_magic( big => ['McHale UNCLE Smart']); # I'd lik +e to use ONE word only # All svgs with Westphall in the name are big, so again no ' right' my $magic = crossover_magic( big => ['Westphall']); my $magic = crossover_magic( big => ['Arriving to Westphall']); # I prefer my $magic = crossover_magic( big => ['Westphall']); my $magic = crossover_magic( big => ['Departing from Westphall']); # I prefer my $magic = crossover_magic( big => ['Westphall']);
Here is textify for you to peruse. It looks messy, but regexen are never pretty for me at least.
sub textify { my ($text, $opt) = @_; my $root_link = base_path('link'); $text =~ s/$root_link\///; # removes the $ro +ot_link $text =~ s/_/ /g; # removes underso +res $text =~ s/ (Mr|Mrs|Ms|Dr) / $1. /g; # adds a period f +or Mr, Mrs, Ms, and Dr; I may need to add more $text =~ s/\s&\s/ & /g; # converts ' & ' +to & $text =~ s/\.{3}/…/g; # converts '...' +to … $text =~ s/(\w|\b|\s|^)'(\w|\b|\s|$)/$1ʼ$2/g; # converts "'" to + ʼ # The following takes out html tags unless I tell it not to $text =~ s/<.+?>//g unless ($opt->{'html'} && $opt->{'html'} + =~ /^[ytk1]/); # The following takes out parenthes unless I tell it not to $text =~ s/\s\(.*?\)$// unless ($opt->{'parens'} && $opt->{'parens' +} =~ /^[ytk1]/); # The following removes file extensions except .com, .net, and .org $text =~ s/\.\w{2,5}?$// unless $text =~ /\.(?:com|net|org)$/; # $text =~ s/(?<!\A)((?<! )\p{uppercase})/ $1/g; # from Kenosis, kcot +t, and tye on PerlMonks # I could not remember what the previous line was doing. return $text; }
My OS is Debian 10 (Buster); my perl version is 5.28.1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I get an exclusion with grep?
by kcott (Archbishop) on Apr 27, 2020 at 10:15 UTC | |
by Lady_Aleena (Priest) on Apr 27, 2020 at 13:07 UTC |