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-
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:
Please use CODE tags for data as well as required by forum rules!
Hello Eric1,
Let me give you a few examples.
If I were to implement at face value what you are asking this would be the result:
Output:
But I suspect that's not what you want. Probably, you would like something more like: Output:
However, depending of the real input, that might have a serious flaw. Name plus last name is not unique enough. There is the strong possibility that two or more entries might contain the same name last-name record even when the data would mean different people. Translation: you loose data, since a hash will keep only the last read.
Adding the birthday to the id might help to prevent that. Here's a modification of the previous code, using a modified input to prove handling of name collision and multi-word decease:
INPUT:
Output:
Note:
The code assumes that the patient will always be name and last-name and not a variation like name alone or name, middle name, last-name, etc...
Once you decide and practice with extracting the data based on actual data, you could show your effort on it and follow up with your second question.
By the way, I hope the example does not contain real people's names and birthdays that you happen to be trusted with. That would be a 'terrible' thing to post.
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)
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)
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)
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)
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)
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)
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)
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)
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)