![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| UNIX newbie NEWBIE question! | Hanamachi | UNIX for Dummies Questions & Answers | 4 | 03-28-2009 04:10 PM |
| newbie to unix programming in C, needed a few simple prgs on these functions! | wrapster | High Level Programming | 1 | 06-22-2008 01:12 PM |
| Perl Newbie - help! | Khoomfire | Shell Programming and Scripting | 1 | 04-24-2008 02:43 PM |
| Programming Newbie Chick | metalgoddess21 | UNIX for Dummies Questions & Answers | 3 | 03-18-2006 09:10 PM |
| programming question from a newbie, please help | milenky | High Level Programming | 1 | 10-11-2002 10:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script. I have a files named in this format 01112008_abcd_xyz.dat (100s of such files) and they are presently in the following directory C:/Doc and settings/myname/rawdata/*.dat My script has to acheive creation of folder C:/Doc and settings/myname/rawdata/abcd/011112008/*.dat so folders have to be created according to part of a name of the .dat files, that i have..then transfer the respective *.dat files inside those folders Plssss help :-( lastly I am using Windows ..thanks xytiz |
|
||||
|
split the filename on _ so you get the middle part and the first part. use module like File::Path or Perl's internal mkdir to create directories.
Code:
use File::Path;
while(<*.dat>){
@l = split /_/,$_;
mkpath(...); # see the doc of File::Path for usage
# or mkdir()
}
|
|
||||
|
Hey ghostDog,
Thanks for the reply.. I have now got to a stage where i have the folder abcd in place but i need to create abcd/011112008/*.dat ..so i used opendir to go inside "abcd" folder and again call makedir function i have written but i think I need to set the o/p put path unlike windows where you open the dir and do create dir :-) .. Again thanks for your help ..any further inputs on this will be very helpful... xytiz |
|
||||
|
Hi ghostDog,
My question was i am unable to create multiple directories :-( below is my code mkpath does not help much either..I have tried few things like "\" and "//" and "\ /" nothing seem to work ... Code:
sub makeDir
{
my $new_dir = shift;
if (!(-e "$new_dir"))
{
mkpath([$new_dir “/” $Date], 1, 0777);
#mkdir ($new_dir $rncDate,777);
print "( $new_dir ) Directory has been created.\n";
}
}# end sub makedir
thanks Xytiz |
![]() |
| Bookmarks |
| Tags |
| perl filehandle subroutine log, perl script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|