in reply to regex and database fields

If you're matching against some $string, \z matches the end of the string.

my $field = '*E2@x*PAP'; $field =~ /\*PAP\z/;

You can also use $, which will match at the end of the string with or without a newline.

my $nl = "newline\n"; my $nonl = "newline"; $nl =~ /line$/; $nonl =~ /line$/;

Update: As Test::More:

use Test::More 'tests' => 3; my $field = '*E2@x*PAP'; ok( $field =~ /\*PAP\z/, '\\z matches at end of string' ); my $nl = "newline\n"; my $nonl = "newline"; ok( $nl =~ /line$/, '$ matches newline at end' ); ok( $nonl =~ /line$/, '$ matches end of string without newline' );