473,230 Members | 1,566 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,230 software developers and data experts.

Pring array into a text file

Hi,
I am veeeery new to perl..
i have a script where i am outputting the Environment variable to a HASH.
either i want to output hash values into a text file,
Or
get hash into an array and then print the array into the text file../
thanks
avashisht
Jul 19 '05 #1
5 9291
as*************@target.com (avashisht) wrote in message news:<40**************************@posting.google. com>...
Hi,
I am veeeery new to perl..
i have a script where i am outputting the Environment variable to a HASH.
either i want to output hash values into a text file,
Or
get hash into an array and then print the array into the text file../
thanks
avashisht


Hi. Try this:

my %hash = ( key1 => 'value1',
key2 => 'value2',
key3 => 'value3',
key4 => 'value4');

open OUT," > file.txt" or die "$!\n";

while (my ($key, $value) = each %hash) {
print OUT "Key: $key , Value: $value\n";
}
close OUT;
Enough ?
Jul 19 '05 #2
how could yOu read them from file.txt and store in memory again?
is there a binary format for hash?
my %hash = ( key1 => 'value1',
key2 => 'value2',
key3 => 'value3',
key4 => 'value4');

open OUT," > file.txt" or die "$!\n";

while (my ($key, $value) = each %hash) {
print OUT "Key: $key , Value: $value\n";
}
close OUT;
Enough ?


--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 5:06pm up 2 days 19:00 load average: 1.00 1.08 1.05
Jul 19 '05 #3
toylet <to****@mail.hongkong.com> top-posts:

[ don't top-post, it is rude ]
my %hash = ( key1 => 'value1',
key2 => 'value2',
key3 => 'value3',
key4 => 'value4');

open OUT," > file.txt" or die "$!\n";

while (my ($key, $value) = each %hash) {
print OUT "Key: $key , Value: $value\n";
}
close OUT;
how could yOu read them from file.txt and store in memory again?
is there a binary format for hash?


There are several modules on CPAN for serializing arbritrary data
structures. One of them is Storable. Another is Data::Dumper.

This newsgroup does not exist (see FAQ). Please do not follow-up here
without pointing this out.
Jul 19 '05 #4
> This newsgroup does not exist (see FAQ). Please do not follow-up here
without pointing this out.


sorry, what did you mean by that? there is an alternative usenet
newsgroup for perl? I frankly found the traffic here a bit low given the
popularity of perl.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 12:04am up 24 min 1 user 0.55 0.24
Jul 19 '05 #5
toylet wrote:
This newsgroup does not exist (see FAQ). Please do not follow-up here
without pointing this out.

sorry, what did you mean by that? there is an alternative usenet
newsgroup for perl? I frankly found the traffic here a bit low given the
popularity of perl.


On one USENET server, this bogus newsgroup of comp.lang.perl has
only 459 articles online. The proper newsgroup comp.lang.perl.misc
has 3146 articles online. Go there for more info.
-Joe
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
2
by: JackM | last post by:
Let me attempt to explain my problem. I have a crude php script that takes a text list of songs that was generated by an mp3 list program and translates each entry into the form where they can be...
5
by: Andrew V. Romero | last post by:
At work we have an excel file that contains the list of medications and their corresponding strengths. I would like to save the excel file as a text list and paste this list into a javascript...
11
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I've noticed a few threads (full of sound and fury, signifying nothing) here recently about allocation of large memory blocks. I'm about to start on a personal pet project where I'll be using...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
7
by: theballz | last post by:
Hi, I am learning c programming and come across a problem i cant seem to solve. I have a file which i wish to parse and put certain lines (which do not contain a hash character) into an array...
8
by: isaac2004 | last post by:
hello, i posted with a topic like this but got no real feedback(prob cuz of lapse in my explanation) so i am trying it again. i am trying to set up a function that brings in a txt file and adds the...
9
by: Autostrad | last post by:
Hi everybody, I need your help. The code below is good if I want to print a sketch. The book did not show how to print a simple text file. Right now if I run this program (as is)it will show...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.