use strict;
my $str = '$$183900057,4002,03/05/2019,22:23:57,33.093139,-97.132556,2213,0.0,0,9,2.3,13.967,27,0,3,0,0.0,0.0,0,0,0,2##';
my $regex = qr/^\$\$(?<uid>\d{9})\,(?<ev>\d{4})\,(?<d>\d{2}\/\d{2}\/\d{4})?\,(?<t>\d{2}\:\d{2}\:\d{2})\,(?<lt>\-?\d{1,3}\.?\d{1,6})\,(?<ln>\-?\d{1,3}\.?\d{1,6})\,(?<al>\-?\d{1,7})\,(?<sp>\d{1,3}\.?\d{0,3})\,(?<hd>\d{1,4})\,(?<sv>\d{1,2})\,(?<hp>\d{1,3}\.?\d{1,2})\,(?<bv>\d{1,5}\.?\d{1,4})\,(?<cq>\d{1,2})\,(?<mi>\d*)\,(?<gs>[012345]{1})\,(?<gt>\d{1,5}\.?\d?)\,(?<ac>\-?\d{1,3}\.?\d{0,3})\,(?<dc>\-?\d{1,4}\.?\d{0,3})\,(?<in1s>[01]{1})\,(?<in1a>\d*)\,(?<in2s>[01])\,(?<ig>[012])\#\#/mp;
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