use warnings; use strict; use Test::More; # this is the regex we're working on my $regex = qr/^ \s* (\d+) \s* \[(\d+)\] \s+ (\S+) \s+ \[(.+?)\] \s* (\w+): \s* (.*?) \s* $/x; { ok my @out = # inside the q{} is the test input string q{ 20848[30892] 0000000000000000 [DM_MQ_I_DAEMON_START]info: "Message queue daemon (tid : 27944, session 0102b20d80000456) is started sucessfully." } =~ $regex; is_deeply \@out, # inside the [] is the expected output (capture group matches) [ '20848', '30892', '0000000000000000', 'DM_MQ_I_DAEMON_START', 'info', q{"Message queue daemon (tid : 27944, session 0102b20d80000456) is started sucessfully."} ] or diag explain \@out; } # ... add more test cases here! done_testing;