I'm getting this error even though I have declared my regex variable.

my $pattern = '(Cat\.\sNo\.\s\d+)';

Later in my code I use then $pattern.

if ($page =~ /$pattern/)
{
  push(@array, $element);
}

But when I run my code it gives me the below error, and continues to run successfully:

Use of uninitialized value in pattern match (m//)

A search on Google for this error seems to point to scenarios where the variable has not been initialised, although in my case it would seem I have initialised it already?

Edit
Report