in reply to Regex not behaving as expected

this works (assuming you want a series of numbers but disregarding leading zeros):
use strict; my $file = 'file013.txt'; my ($sk) = $file =~ m/0*(\d+)/; print $sk;
The problem with the way you had it is that it is returning 1 not because of the number 1 in the 013 but because it is true (akai.e., there was a match).

-enlil

Replies are listed 'Best First'.
Re: Re: Regex not behaving as expected
by Popcorn Dave (Abbot) on Feb 01, 2003 at 00:48 UTC
    Yes that's exactly what I was after. Thanks for that, I think it's been too long of a day. I can't believe I didn't catch that. :|

    Also thank you for the ($sk) bit. I never realized that you didn't have to use $1, $2, etc... in matching.

    There is no emoticon for what I'm feeling now.