#!/usr/bin/perl use strict; use warnings FATAL => qw( all ); use Text::Balanced qw(extract_bracketed); use Data::Dumper; my $text = 'A line with B, I, and B> text.'; my @line = extract_bracketed( $text, '<>'); print Dumper(\@line); #### $VAR1 = [ undef, 'A line with B, I, and B> text.', undef ];