Your method will mostly work as long as you’ve got Settings > Preferences > Backup correctly enabled, and you have a short enough backup time. If you want to make sure it’s got enough time to register the changes in the file, add a sleep($time) before the check, where $time matches your NPP backup interval.
I would probably add a test for existence of the backup file, not just it being listed in session.xml. (I just ran an experiment, and a minute after my most recent save, when the backup file was gone, session.xml still listed the backup file). I would also use -M to check the modified-time of both the original and the backup, since I found outdated “backups” in my backup directory that were months out of date (probably remained open after a reboot or crash).
Also, if you find that the file hasn’t been saved yet, you could also use Win32::OLE or Win32::GuiTest to force NPP to save the file, if you wanted, instead of just pestering yourself with a message box. But that’s up to you.
PS: Perl is not an acronym: “Perl” is the language, “perl” is the executable/interpreter, “PERL” is a backronym.