Q:

Perl String remove a part of it after a pattern

I have a variable my $html and it holds a string value. I want to cut it after the word
</SELECT>

How can I do that with Perl?

A:

use warnings;
use strict;

my $html = '<SELECT>foo</SELECT> bar';
$html =~ s{(</SELECT>).*}{$1};
print "$html\n";

__END__

<SELECT>foo</SELECT>

You should also consider using one of the many HTML parsers on CPAN.

