Yes, that's one of the solutions MidLifeXis proposed and I think it's also considered a Perl "best practice".
In reply to Re^4: var comparison by nemesisgus in thread var comparison by nemesisgus