473,386 Members | 1,610 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.

logic problem

Hello friends,

I have a directory Z with file name Z.txt.
I would like to copy this file Z.txt to 8 new dir with new filenames as follows
dir 1 1.txt
dir 2 2.txt
dir 3 3.txt
dir 4 4.txt
dir 5 5.txt
dir 6 6.txt
dir 7 7.txt
dir 8 8.txt

I would like to then open 1.txt from dir 1 and edit the first 4 lines and it
would be better if the program can ask me what to enter in these lines. I need
to do the same for all the directories

Looking forward to your response.

Regards,
Ramesh
Jul 7 '08 #1
3 1186
nithinpes
410 Expert 256MB
Please do not post your homework questions here. Let us know what you have tried so far and where you are facing problem, so that someone here can help you.
Jul 7 '08 #2
Hi all,

I have tried the following, I know the logic behind it, but i am unable to put it rightly using the Perl format. I have tried the following

#!/usr/bin/perl
open FILE, "z.txt" or die $!;
while (<FILE>) {
print $_;
}
mkdir("1", 0777) || print $!;
mkdir("2", 0777) || print $!;
mkdir("3", 0777) || print $!;
mkdir("4", 0777) || print $!;
mkdir("5", 0777) || print $!;
mkdir("6", 0777) || print $!;
mkdir("7", 0777) || print $!;
mkdir("8", 0777) || print $!;
print " -Done";

exit;

I am have all the new directories with respective names. I want to copy the file z.txt from dir z to the new dir 1 with file name 1.txt , dir 2 with file name 2.txt and so on...
How could I use the copy function here.
Looking forward to your response.

Regards,
Ramesh
Jul 7 '08 #3
KevinADC
4,059 Expert 2GB
perl has no copy function. You would use the File::Copy module or simply use the open() function to open and read the file and then use "print" to write it to the new directories.

This is not a logic problem. This is an excersize in learning basic file IO operations or possibly more specifically how to mkdir and copy files. Any perl book/tutorial that covers "File Access" or "File IO" should provide you more than enough information to accomplish this very simple task.
Jul 7 '08 #4

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

Similar topics

4
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
0
by: radha | last post by:
Hai all, My problem not just releated to sql. My problem is releated to good logic. I should not this type of questions hear. But just i am trying. If any body gave suggestions, or help i am...
60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
0
by: davidpendry | last post by:
Hi, I have created a asp.net online booking service for a client using n tier logic producing the follwing dll's: bookings_business.dll bookings_config.dll bookings_data.dll
5
by: Nate | last post by:
We are attempting to make a request to a web service (we will refer to it as XXXServices) hosted on a Web Logic server from a C# SOAP client. The server responds with a 401 Unauthorized error...
24
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
0
by: emparc | last post by:
Hello Gurus, I am a newbie to SQL without any formal training (using Navigator 5) and reached a dead-end on trying to figure out the logic and the coding I need to make this work ! Your...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
15
by: bruno.desthuilliers | last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.