Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- my $pattern = '(?<word>\b\w*a\b)';
- print "\$pattern = $pattern\n\n";
- print "Type a string to see if it matches.\n";
- while (<STDIN>) {
- chomp;
- if ($_ =~ m/$pattern/) {
- printf "%-40s %s\n", "Matched: |$`<$&>$'|", "\$+{word} contains $+{word}";
- }
- else {
- printf "%-50s\n", "No match: |$_|";
- }
- }
- print "done.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement