use strict; use warnings; use Test::More tests => 4; my $tomatch = 'GigabitEthernet1/0/48'; my $notmatch = 'GigabitEthernet1/0/49'; my $yourgo = qr/(^gi.*)([1-8])(\/)(0)(\/)([1-9]|[1-3][0-9]|4[0-8])/i; my $mygo = qr/(^gi.*)([1-8])(\/)(0)(\/)([1-9]|[1-3][0-9]|4[0-8])$/i; like ($tomatch, $yourgo, "$tomatch matches"); unlike ($notmatch, $yourgo, "$notmatch does not match"); like ($tomatch, $mygo, "$tomatch matches"); unlike ($notmatch, $mygo, "$notmatch does not match");