Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: parse filenames

by trs80 (Priest)
on Apr 12, 2002 at 16:42 UTC ( [id://158626]=note: print w/replies, xml ) Need Help??


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/([^\.]+)$/;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://158626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (1)
As of 2024-04-24 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found