If you look here the perldoc says, "my($x) creates a new variable x that is only visible in the current subroutine." So assuming that the if statement block is in the same subroutine, I believe $database is still local.
Don't believe everything you read. That simply isn't a very good explanation of my() and lexical variables. Lexical variables are visible only in their enclosing file, block, or eval.