Using your first example:
#!/usr/bin/perl
use strict;
use warnings;
$currentSentence =~ s/[\ba\b|\ban\b|\bthe\b]//g;
exit;
I get the following:
P:\>rmv1.pl
Global symbol "$currentSentence" requires explicit package name at P:\
+rmv1.pl line 4.
Execution of P:\rmv1.pl aborted due to compilation errors.
Then I fixed the error on line 4:
#!/usr/bin/perl
use strict;
use warnings;
my $currentSentence =~ s/[\ba\b|\ban\b|\bthe\b]//g;
exit;
Which yields the following:
P:\>rmv2.pl
Use of uninitialized value $currentSentence in substitution (s///) at
+P:\rmv2.pl line 4.
So, to fix that, I added a value based on your loose description:
#!/usr/bin/perl
use strict;
use warnings;
my $currentSentence = "The big dog rolled in an open field filled with
+ a type of grass.";
$currentSentence =~ s/[\ba\b|\ban\b|\bthe\b]//g;
exit;
I get the following:
P:\>rmv3.pl
P:\>
Now morbidly curioius, I added a line to display the result:
#!/usr/bin/perl
use strict;
use warnings;
my $currentSentence = "The big dog rolled in an open field filled with
+ a type of grass.";
$currentSentence =~ s/[\ba\b|\ban\b|\bthe\b]//g;
print "[$currentSentence]\n";
exit;
I get the following:
P:\>rmv4.pl
[T big dog rolld i op fild filld wi yp of grss.]
I'm now going to ask the question:
What's with all the \baction in your regular expression?