use strict;
my $str = '# started 2015-11-29T18:23:17Z
<http://dbpedia.org/resource/Bobcat_Company> <http://dbpedia.org/property/type> <http://dbpedia.org/resource/Subsidiary> .
<http://dbpedia.org/resource/Bobcat_Company> <http://dbpedia.org/property/website> <http://www.bobcat.com> .
<http://dbpedia.org/resource/Albedo> <http://dbpedia.org/property/colwidth> "30"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/voy> "no"@en .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/n> "no"@en .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/v> "no"@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/keyPeople> "Kevin Knight"@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/keyPeople> "Keith Knight"@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/numEmployees> "4400"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/industry> "motor transportation-trucking"@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/products> "truckload shipping"@en .
';
my $regex = qr/<(\S+)>\s*<(\S+)>\s*(?:"(.+)"|<(\S+)>).*./p;
if ( $str =~ /$regex/ ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html