in reply to positive integer identification (regular expression question)

I want to adapt this to identify $ref as a negative integer.

then you want:

($ref =~ /^-[1-9]\d*$/)
(i.e. change !~ to =~)

hope this helps,