in reply to pattern matching

I assume you mean something like this (you really should've clarified, and for that I point you to What makes a bad question? Before You Post ... How (Not) To Ask A Question How to ask questions the smart way )
#!/usr/bin/perl -w use strict; my $String = "Noo S pro NpppT Nop| NPP"; my $LongString = "YYY DDD $String RRR PPP"; my $Pattern1 = qr{N[^P]{2,4}[S|T]}; my $Pattern2 = qr{DDD\s}; for my $m ( $LongString =~ m{($Pattern1|$Pattern2)}g ) { print "Yes! $m\n"; } __END__ Yes! DDD Yes! Noo S Yes! NpppT Yes! Nop|
Because you didn't format your question properly, I point you to site how to and (OBE) The Perl Monks FAQ

Because it's interesting, and potentially of use, I point you to Why I like functional programming by tilly.

I suggest you give a good gander to all of the links I provided you with (you might not get instant satisfaction, but you'll find 'em all useful, even if it takes a little while)