in reply to Perl RegEx doubt

Read perlre and then compare /./ against /.?/. The question marks make the dot optional.

Most likely, you want something like the following:

/^....p.$/

Note the anchors ^ and $ (or alternatively, \A and \z). I've also removed the /i modifier, because you seem want to match a lower-case p only.