Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Probably silly regex question / not so silly regex question

by princepawn (Parson)
on Aug 02, 2000 at 12:28 UTC ( [id://25679]=note: print w/replies, xml ) Need Help??


in reply to Probably silly regex question / not so silly regex question

As I look at all 10 or so posts above this one, I am staggered to see that noone has mentioned File::Basename as an architecture independant way to get either the basename or extension or path of any filename:
use File::Basename $basename = basename($filename);
Should work... but there is no Perl interpreter in a window for me here at Perl Monks (hint).

Replies are listed 'Best First'.
RE: Re: Probably silly regex question / not so silly regex question
by barndoor (Pilgrim) on Aug 02, 2000 at 15:07 UTC
    I was just going to write that... I use File::Basename all the time for filename splitting. Hasn't failed me yet and heres how you do your bit.
    use strict; use File::Basename; my $file = '/ftp/dest/id.ext'; my ($name, $path, $suffix); my @suffixes = ('.ext'); # Extra extensions can be added to the list. ($name, $path, $suffix) = fileparse($file, @suffixes);
    Coffee, KitKat, and a new script to write. It's gonna be a good day....

      Ah, beutiful. I saw File::Spec (and use it), but I missed File::Basename.

      Thanks,
      James Mastros,
      Just Another Perl Initate

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-03-28 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found