Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

capturing from path

by amoura (Initiate)
on Jul 09, 2002 at 20:43 UTC ( #180602=perlquestion: print w/ replies, xml ) Need Help??
amoura has asked for the wisdom of the Perl Monks concerning the following question:

Hello ,,,,,

I got this directory/cnn/src/you.cpp:me.cpp and I need to to get the files and store it in variables so

$main = cnn; $you = you.cpp; $me = me.cpp;

any ideas of easy way :)!!!

Edited 2002-07-09 by mirod: added <p> and <code> tags

Comment on capturing from path
Select or Download Code
Re: capturing from path
by Aristotle (Chancellor) on Jul 09, 2002 at 20:50 UTC

    Hiya.

    Your question is rather unclear - do you want to store the files' contents' in the variables or just the filenames?

    In either case you will need readdir. In case you want to read the files, you will also need open and close as well as the <FILEHANDLE> operator.

    Once you explain yourself more clearly, we can provide more specific answers as well.

    Makeshifts last the longest.

Re: capturing from path
by Fastolfe (Vicar) on Jul 09, 2002 at 20:57 UTC
    To break a path up into directory and file components, you can either split on the / character, or for a more portable solution, use File::Spec's splitpath and splitdir functions.
Re: capturing from path
by Fastolfe (Vicar) on Jul 09, 2002 at 21:19 UTC
    You may also be interested in reading the responses to these nodes below, as a very similar question was also asked today by one of your classmates:

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2014-07-29 03:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls