in reply to Regex not behaving as expected

m// in scalar context returns true or false if it succeeds or fails. In list context without /g it returns the list of $1, $2, ... if you have used () to capture anything. In short you probably want to use:
use strict; my $file = 'file013.txt'; my ($sk) = $file =~ m/(\d+)/; # list context to get what () captured print $sk;
See perldoc perlop for more info on various combinations of m//, /g and what they return in list and scalar context.

Update: Corrected typo.