in reply to Re^2: Use of uninitialized value $1
in thread Use of uninitialized value $1

my $v = '/path/to/module.pm'; $v =~ m{^(.*)/(.*)$}; say "($1) ($2)";

prints out:

(/path/to) (module.pm)

Thus, if you want your module name hardcoded:

my $modulepath; if($v =~ m{^(.*)module.pm$}){ $modulepath = $1; }

additional note: usually you write m// with slashes, but I write it with m{} brackets. This is also valid and allows you to use / inside the regexp, without having to escape it with a backslash.