From 17a350c8d6ec2ae887fe7784dd6b9275028dc681 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Mon, 20 May 2024 22:54:52 +0100
Subject: [PATCH 1/3] seg-validate.pl: Use qr// instead of strings to assemble
 regexes

Also eliminate unused captures, and fix the plus/minus syntax to
accept (+-), not the erroneous '+-'.
---
 contrib/seg/seg-validate.pl | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/contrib/seg/seg-validate.pl b/contrib/seg/seg-validate.pl
index 22cbca966d..518fbfb24a 100755
--- a/contrib/seg/seg-validate.pl
+++ b/contrib/seg/seg-validate.pl
@@ -5,15 +5,15 @@
 use strict;
 use warnings FATAL => 'all';
 
-my $integer = '[+-]?[0-9]+';
-my $real = '[+-]?[0-9]+\.[0-9]+';
+my $integer = qr/[+-]?[0-9]+/;
+my $real = qr/[+-]?[0-9]+\.[0-9]+/;
 
-my $RANGE = '(\.\.)(\.)?';
-my $PLUMIN = q(\'\+\-\');
-my $FLOAT = "(($integer)|($real))([eE]($integer))?";
-my $EXTENSION = '<|>|~';
+my $RANGE = qr/\.{2,3}/;
+my $PLUMIN = qr/\Q(+-)/;
+my $FLOAT = qr/(?:$integer|$real)(?:[eE]$integer)?/;
+my $EXTENSION = qr/[<>~]/;
 
-my $boundary = "($EXTENSION)?$FLOAT";
+my $boundary = qr/$EXTENSION?$FLOAT/;
 my $deviation = $FLOAT;
 
 my $rule_1 = $boundary . $PLUMIN . $deviation;
@@ -28,23 +28,23 @@
 {
 
 	#  s/ +//g;
-	if (/^($rule_1)$/)
+	if (/^$rule_1$/)
 	{
 		print;
 	}
-	elsif (/^($rule_2)$/)
+	elsif (/^$rule_2$/)
 	{
 		print;
 	}
-	elsif (/^($rule_3)$/)
+	elsif (/^$rule_3$/)
 	{
 		print;
 	}
-	elsif (/^($rule_4)$/)
+	elsif (/^$rule_4$/)
 	{
 		print;
 	}
-	elsif (/^($rule_5)$/)
+	elsif (/^$rule_5$/)
 	{
 		print;
 	}
-- 
2.39.2

