473,471 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to write to a file under appropriate block?

25 New Member
Hi,

I have a file which is in the following format:

This file is classify.txt
#######Alphabets#########
.
.
.
#######Numbers##########
.
.
.

In my perl program, I initialize an array which has both numbers and alphabets.
I open the classify.txt file for writing.

1. The program will check each and every element in the array using the foreach loop.

2. It has to then write to this classify.txt file accordingly under either Alphabets or Numbers. [That is, if the element is a alphabet, it has to write under the #######Alphabets######### and if it is a number, it has to write under the #######Numbers########## block in classify.txt file]

I have no problem with the first part.

Can someone please let me know how I can write to a file like the way I mentioned in [2].

I would appreciate your response.

Thanks,
Sangeetha
Jun 27 '07 #1
5 1413
KevinADC
4,059 Recognized Expert Specialist
Lets see what you have tried so far.
Jun 28 '07 #2
miller
1,089 Recognized Expert Top Contributor
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Jun 28 '07 #3
sangith
25 New Member
Thanks Miller for the useful advice. I totally agree. I am not a student.
Although I should'nt be lazy to think. Programming is a lot of fun only if I think and attempt the problem myself. That will also help me learn so much.
I will definitely post questions only if I face any difficulty in the middle.

Thanks.
Sangith
Jun 28 '07 #4
sangith
25 New Member
Lets see what you have tried so far.
Right now, I am reading the file into an array and then using Regex, I am trying to place the elements under appropriate sections. I am positive that I am going to finish this problem with my approach.

Thanks,
Sangith
Jun 28 '07 #5
KevinADC
4,059 Recognized Expert Specialist
Right now, I am reading the file into an array and then using Regex, I am trying to place the elements under appropriate sections. I am positive that I am going to finish this problem with my approach.

Thanks,
Sangith

Very good. If you get stuck ask a question, but please post the code you have written up to that point.

Regards,
Kevin
Jun 28 '07 #6

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

Similar topics

7
by: Patrick Useldinger | last post by:
Hi, I think I found a bug in the write method of file objects. It seems as if before writing each block, a check was done in order to verifiy that there is enough space left for the *whole*...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
8
by: Roberto Rocco | last post by:
Hello, I have a struct and want to stream it to a file (binary). I cannot use because this is not supported under the Compact Framework. What is the best approach to use? Another question in...
2
by: rr | last post by:
Hi, i have to write a file composed of n packets of a given length. I need to write this file writing every packet when i get it, knowing its number and length. I mean: packet #0 -length 100...
4
by: welch | last post by:
while taking some rough disk performance measures on windows machines, and snooping with FileMon, i've noticed some odd behavior here's the little nul-writer i'm running: def writeTest(nBlocks,...
3
by: dnatzic | last post by:
// I have a block of code that runs okay but I need to write all the data to a file placing the appropriate label between each section of output. How would I do that?. import java.io.*; public...
16
by: Hans Fredrik Nordhaug | last post by:
I'm trying to write to a file in the current directory - no remote files. The subject says it all - I can add that both the directory and the file is wordwritable. This happens on a (quite good)...
16
by: vizzz | last post by:
Hi there, i need to find an hex pattern like 0x650A1010 in a binary file. i can make a small algorithm that fetch all the file for the match, but this file is huge, and i'm scared about...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.