How to store info from a txt file into a hash?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to store info from a txt file into a hash?
Prev   Next
# 1  
Old 05-19-2017
How to store info from a txt file into a hash?

I'm trying to make a perl script using the "open" command to open and read a file, storing the information in said file into a hash structure.

This is what is inside my file-

Code:
Celena Standard  F 01/24/94 Cancer 
Jeniffer Orlowski  F 06/24/86 None
Brent Koehler  M 12/05/97  HIV
Mao Schleich  M 04/17/60  Cancer
Goldie Moultrie  F 04/05/96  None
Silva Rizzo  F 10/26/78  Amyloidosis
Leatha Papenfuss  F 10/15/97  CREST
Vita Sabb  F 05/28/87  Autism
Alyce Ugarte  F 12/21/64  HIV
Ela Prout  F 12/05/57  Autism
Mohamed Buchannon  M 07/24/91  Caner
Lael Stall  M 12/05/97  None

The first column is a name, the second is gender, third is birthdate, fourth is disease. The name is supposed to be the key while the other three columns are the values.

Also how would I allow the user to change information and output information to another file?


Moderator's Comments:
Mod Comment Please use CODE tags for data as well as required by forum rules!

Last edited by RudiC; 05-20-2017 at 01:28 AM.. Reason: Added CODE tags.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

2. Shell Programming and Scripting

Store a column from an excel sheet (exported to txt) into a variable

I typically pull a bunch of data via SQL that lists a bunch of users and the server on which they want to access, as well as other attributes, in one row of an excel sheet and the number of rows is directly proportionate to the number of users. I'm trying to write a loop to read each line of the... (2 Replies)
Discussion started by: MaindotC
2 Replies

3. Shell Programming and Scripting

Store output of DB Cursor to a txt file

I am writing a cursor to select values from 3 tables. I want to store these values in a txt file which I will be sending via ftp. I am able to store the results of simple select queries to the txt file. but I am not sure how to store the values when using a cursor. I have given the sql query below.... (1 Reply)
Discussion started by: naveensraj
1 Replies

4. Programming

store information in hash and display number of keys.

I am trying to store this information (info and number) in hash. number is the key and info is value in a hash.i shown my code below. #!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; my $file;open $file, 'formal.xml'); my $reader =... (0 Replies)
Discussion started by: veerubiji
0 Replies

5. Shell Programming and Scripting

How to store the sql query output into txt file?

Hi I want ot save SQL query result in one txt file. for that i have written one code line sqlplus -s $dbstring @/usr/local/bin/sched/nightly_Cronjob/exec_123.sql >> /usr/local/bin/sched/nightly_Cronjob/result.txt but it is not working . database : Oracle so please advice me how can i... (7 Replies)
Discussion started by: Himanshu_soni
7 Replies

6. Shell Programming and Scripting

Generate a mail when you add info to a txt file

Hi, I have an application's log file: /var/log/logfile which is feeded from time to time due to an application. This file contains data, what I want is: -Whenever some new data is copied to /var/log/logfileI want to generate an email to root BUT only with the new added data in the body.... (6 Replies)
Discussion started by: iga3725
6 Replies

7. UNIX for Advanced & Expert Users

Perl loop txt and check if a hash key

Hi, The task i have to do is to 1- create a database contains the Names .run the query and store results in hash make the Name field is the hash key 2- in the same time i have a txt which i will loop through it word by word and check for each word if a hash key ( compare it with the Names in... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

8. Shell Programming and Scripting

Open txt and store line in a var

Hi I realy need to find a way to do a script that does the following: search a word in a txt file then store on a var the letters that are on the right like this is an exemple, I want to store from here ...abcdefg... so I need a var that receive ...abcdefg... Is that possible?... (8 Replies)
Discussion started by: ruben.rodrigues
8 Replies

9. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

10. UNIX for Advanced & Expert Users

When a file is created where does unix store the info?

When a file is created where does unix store the information about the file? (5 Replies)
Discussion started by: goodmis
5 Replies
Login or Register to Ask a Question