local $_ = 'foo'; say 'Start' if /\G foo/gcx; say 'Mid' if /\G .*/gcx; say 'End' if /\G \z/gcx; #### Start Mid #### say 'Mid' if /\G .+/gcx; #### Start Mid End #### perl -E 'local $_ = "foo\n"; say "Start" if /\G foo/gcx; say "Mid" if /\G .*/gcx; say "End" if /\G (?=\n)/gcx'