in reply to Re: adding a return to a file
in thread adding a return to a file

My Actual Question(Sorry I Didnt put this in the first time) Was I Have a list of words and definitions

ex

accession n. Induction or elevation, as to dignity, office, or government. and i want it to look like this

accession

n. Induction or elevation, as to dignity, office, or government.

and then i want to turn it into a hash because i am making a dictionary

Replies are listed 'Best First'.
Re^3: adding a return to a file
by AlexanderTheGreat (Initiate) on May 17, 2012 at 16:21 UTC

    I am going to add my code so you guys can take a look at what i have so far

    #! /usr/bin/perl use warnings; use strict; #opening the file that i am reading from open TEST, 'test.txt' or die $!; #saving the file as a hash my %test = <TEST>; #looping through the hash and printing out all the words # i am going to eventualy have the person enter a sylable to look up r +hyming words for (keys %test) { print "$_"; } # and then give the definition of the word that you type in print " Please Enter A Word "; my $choice = <STDIN>; #the vaariable to check if the word is in the file my $word = 10; for (keys %test) { #if it is print out the definition (the hash value) if ($choice eq $_) { print $test{$_}; $word = 1; } } close TEST; #if it is not then say sorry word not found and ask them to retype it +and a definition if ($word != 1) { open TEST, '>>test.txt' or die $!; print "Sorry Word Not Found\n"; print "Please Re-enter Word\n"; my $input = <STDIN>; print "Please Enter Definition\n "; my $def = <STDIN>; #append the word to the file print TEST "\n",$input; print TEST $def; }

      I have solved my problem with the split command thank you all for your help

      AlexanderTheGreat

Re^3: adding a return to a file
by Anonymous Monk on May 17, 2012 at 16:09 UTC

    That's not a question.

    Looks a bit like a task description, but what's the pay?

      Wait you want to get paid?????????

      i am trying to figure it out not pay somebody to make the program for me

        Wait you want to get paid?????????

        It seems someone has hit you with a big clue bat, and this time, it worked ... ;-)

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)