Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

How to change directory recursivly

by perladdict (Chaplain)
on Jun 20, 2007 at 14:09 UTC ( #622249=perlquestion: print w/ replies, xml ) Need Help??
perladdict has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have around 200 vobs(versioned objectbase in clearcase) like as unix directories
i have to run a clearcase command on each vob to unchekout all the null versions of elements of all the branches.
for running this command each time i ahve to change the directory path to vobtags of all 200 directories,so 200 times i have to run this command manually...
I am trying by storing all the vobtags in one array and calling each tag by using loop,in that i am using chdir function after that i am executing the below command
but its not working....it is an one type of trigger in clearcase....can any one help me out to how can i change the the path to the each element of an array....
`$CT mktrtype -replace -element -all -nc -posto uncheckout execunix "/ +usr/bin/perl /usr/addon/puccase_admin/ viewtools/unixbin/triggers/empty_br.pl" -execwin "ccperl.exe \\\\ punas01\\puccase_admin\\viewtools\\unixbin\\triggers\\ empty_br.pl" postop_unco_1`; Solution to this will be a greate help for me......

Comment on How to change directory recursivly
Download Code
Re: How to change directory recursivly
by blazar (Canon) on Jun 20, 2007 at 14:32 UTC
    I am trying by storing all the vobtags in one array and calling each tag by using loop,in that i am using chdir function after that i am executing the below command

    I'm not sure if I understand your question, let alone if it is actually a Perl question at all. But if you have, say, a @files array which contains a list of filenames complete of full paths, then what's wrong with the following? (Or some obvious and perhaps better written modification of it.)

    use File::Basename; use Cwd 'abs_path'; # ... for (@files) { my ($name, $path)=fileparse $_; chdir abs_path $path; do { Something::with($name) }; }
Re: How to change directory recursivly
by Moron (Curate) on Jun 20, 2007 at 14:50 UTC
    Rather than shell out 200*N times where N is the number of operations per file, it is better (and walks around the problem you pose!) to use e.g. IPC::Open3 to maintain a dialogue with a single clearcase session (one process only!. It also means you don;t have to cd 200 times either. e.g.:

    Actually I don't need to code this e.g. - it's all been done before in ClearCase::Proc::ClearTool. One of these days I'll have to give up coding and let cpan do it all ;)

    __________________________________________________________________________________

    ^M Free your mind!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-08-31 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls