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

How to seperate directory and file

by Divakar (Sexton)
on Sep 14, 2012 at 07:10 UTC ( #993661=perlquestion: print w/replies, xml ) Need Help??
Divakar has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

i have to split directory and file from below lines.


from this i have to get like this.



i dont know how to split and get it.

any help please?

Thank you...

Replies are listed 'Best First'.
Re: How to seperate directory and file
by kcott (Canon) on Sep 14, 2012 at 07:41 UTC

    G'day Divakar,

    The built-in module File::Spec has a number of functions for manipulating pathnames: splitpath() would be the one to use here.

    -- Ken

Re: How to seperate directory and file
by ramesh824 (Initiate) on Sep 14, 2012 at 07:18 UTC
    You can use basename and dirname functions from "File::Basename" CPAN module to achieve this.
Re: How to seperate directory and file
by Anonymous Monk on Sep 14, 2012 at 08:22 UTC
    $ perl -E " use Path::Class; my $path = file(q[/ro/sham/]); say +$path->parent; say $path->basename; " \ro\sham

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://993661]
Approved by kcott
[Corion]: Meh. I think I have now the parts down that I want from a simple Javascript frontend for single-page- applications with a aPerl backend. But it seems that all Javascript templating modules either don't support two-way binding (which would be nice) or ...
[Corion]: ... don't support server-side precompilation (which means the client has to compile all templates to Javascript themselves), or are giant frameworks that expect to do everything (which is not what I want)
[Corion]: I feel that there is a talk somewhere in there, either about the structure and parts, or how I used several parts to get a complete whole.
[Corion]: Maybe I can still find something that is compatible with handlebars.js (which has JS precompilation) but allows for two-way data binding (which is great for the UI)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2017-03-30 07:44 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (355 votes). Check out past polls.