in reply to Re^2: position of first matching regex
in thread position of first matching regex

Why print if the match fails?

Note that my code includes strictures (use strict; use warnings;). That will warn you of such unhealthy coding practises. I strongly recommend you use strictures, especially if you are just starting out with Perl.

The () around your two assignment statements don't add any value and make understanding the intent of your code harder.

@array is not a scalar reference. It is the array.

Perl is the programming world's equivalent of English