in reply to parse filenames

You can use a regex of substr to do this.
my ($numbers) = $file =~ m/(\d{3})$/;
or
my $numbers = substr ($file, -3, 3);
The latter is much faster then the former, but personal preference may dictate which you decide to use.

Replies are listed 'Best First'.
Re: Re: parse filenames
by CukiMnstr (Deacon) on Apr 12, 2002 at 17:28 UTC
    just to be on the safe side (in case the suffix contains letters or is longer than 3 chars):
    my $suffix = $file =~ m/\.(.+)$/;

    hope it helps,

      Make sure the file doesn't have more than one dot..

      my ($suffix) = $file =~ m/([^\.]+)$/;