#!/usr/bin/perl -w use strict; print 'Please enter the RE to test: '; chomp( my $regexp = ); print "Please enter your strings ('QUIT' to exit):\n"; print 'regex> '; while ( ) { chomp; last if /^QUIT$/; if ( /$regexp/ ) { print "Match: |$`<$&>$'|\n"; } else { print "No matches.\n"; } print 'regex> '; }