You can create a regular expression once and reuse it on each string.
#!/usr/bin/env perl use strict; use warnings; my @del_words = qw{is an to for from}; my $del_words_alt = join q{|} => @del_words; my $del_re = qr{\b(?>$del_words_alt)\b\s*}; while (<>) { s{$del_re}{}g; print; }
Test run:
$ pm_string_array_del.pl is that true that true this is from presentation this presentation to create create
-- Ken
In reply to Re: Deleting values from string using array
by kcott
in thread Deleting values from string using array
by Shaveta_Chawla
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |