#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; { local $_ = 'foo'; say '1 Start' if /\G foo/gcx; say '1 Mid' if /\G .*/gcx; say '1 End' if /\G \z/gcx; } { local $_ = 'foo'; say '2 Start' if /\G foo/gcx; say '2 Mid' if /\G .+/gcx; say '2 End' if /\G \z/gcx; }