Use an "if" statement to check the return of
s/// (returns the number of substitutions made; false otherwise):
use strict;
use warnings;
my @items = ('"Title Text Example1"', 'Title Text Example2', ' Title T
+ext Example3 ',' "Title Text Example4"');
foreach my $title (@items) {
my $match = 0;
$match++ if $title =~ s/^[\s"]+//;
$match++ if $title =~ s/[\s"]+$//;
print "$title.\n" if $match;
}
__END__
Title Text Example1.
Title Text Example3.
Title Text Example4.
Updated to match both begin and end.