use strict; use warnings; $_ = 'Page 1 of 5'; if(/Page\ \;1\ \;of\ \;(\d+)/) { print "Number of Pages = ".$1; } __OUTPUT__ Number of Pages = 5