473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem regarding mkdir and chdir and recursive function

Hi All,
I have data in 20 different folders named from step_1...step_20 and each folder has some files which I am trying to manupulate and after that my program should make directories named step_1_results .... step_20_results and write each results into the respective directory. But somehow my code is not making directories and writing files INTO them instead writing them outside the directories.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. my $folder = "/home/r/surface_tension/";
  6. opendir(FO,$folder);
  7. my @fols = grep {/step_*/} readdir(FO);
  8. #print "@fols\n";
  9.  
  10. foreach my $foss(@fols)
  11. {
  12.     opendir(FOL,$foss);
  13.     my $folname = $foss;
  14.     #print "$foss\n";
  15.  
  16.    my @filess = grep {/\.out$/} readdir(FOL);
  17.     #for(my $i=0;$i<@filess;$i++)
  18.     #{
  19.         #print "$filess[$i]\n";
  20.     #}
  21.     foreach my $eva(@filess)
  22.     {
  23.         $name = $eva;
  24.         $name=~ s/\.out/.pmt/g;
  25.         print "$name\n";
  26.         `mkdir -p $foss_results`;
  27.          `cd $foss_results`;
  28.         open(WRITE,"$name_result");
  29.     }
  30.  
  31. }
  32.  
Thanks for Help
Kumar
Apr 15 '08 #1
0 1177

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nicholas Geraldi | last post by:
I have a script that uses the chdir() function. I know the script works ( works perfectly on my host ), but when I put the script on my server here at work I get the following error. Warning:...
2
by: Shaun | last post by:
Hello! I can't seem to get paths and variables working together: import os a = 'books' os.chdir( '/test') os.mkdir("/test/"a) the last line does not seem to work. os.mkdir(a) makes the...
4
by: m.wanstall | last post by:
Hi there, I'm totally new to Python and was wondering why I was getting an error for this. I'm just trying to create a folder based on user input: import os def setupProject(project):...
7
by: per9000 | last post by:
Dear Black Knight, I have no quarrel with you sir Knight, but I must import your parents. SHORT VERSION: I tried three variants of "from ../brave.py import sir_robin", one works. I want...
5
by: eoindeb | last post by:
I am trying to create a directory on Solaris using the mkdir() function. This works fine when I pass a string literal ("/etc/hosts") to mkdir, but if I try passing a directory pointer to mkdir, it...
30
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the...
2
by: boytheo | last post by:
Hi people, I'm trying to get a script to create a few directories on a webserver, and unzip a file or two. my script works fine locally, when accessed via shell. When accessd via apache, it...
0
by: Julien Biezemans | last post by:
Hi everyone, I've written a file:// scheme stream wrapper that acts like chroot() (but is more flexible, does not require root privileges and works on any platform). Everything works just fine...
1
by: Damodhar | last post by:
hi any one can help me to create the folder and sub folders for ex my project root is : test i want to create the folder like files/images/personal/profile/album/ damu i want to create...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.