use strict;
my $str = '# ---------------------------------------------------------------------------- #
# Packages
# ---------------------------------------------------------------------------- #
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_1_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_2_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_3_test_1_qip.vhd"]
# Register Tool set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_INVALID_test_1_qip.vhd"]
# ---------------------------------------------------------------------------- #
# Sub Modules
# ---------------------------------------------------------------------------- #
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) "module_test_2.qip"]
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) "module_test_3.qip"]
# ---------------------------------------------------------------------------- #
# Module Files
# ---------------------------------------------------------------------------- #
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_4_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_5_test_1_qip.vhd"]';
my $regex = qr/(?<!#)(?:(?<=_FILE).+"(.+)")/p;
if ( $str =~ /$regex/g ) {
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