Permalink
Browse files

completed namedCapture exercise

  • Loading branch information...
1 parent bf2a326 commit 84c24e261953248e61a464139e23066e94422198 @crlane committed Mar 3, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 chapter8/namedCaptureEndsWithA
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+use strict;
+use 5.010;
+
+my $pattern = '\b(?<word>[\w]*a)\b';
+
+while (<>) { # take one input line at a time
+ chomp;
+ if (/$pattern/) {
+ print "Matched: |$`<$&>$'|\n"; # the special match vars
+ print "\$+{word} contains '$+{word}'\n";
+ } else {
+ print "No match: |$_|\n";
+ }
+}
+

0 comments on commit 84c24e2

Please sign in to comment.