MinniePerl
Technical User
Thanks mucho to stillflame on my last problem with this.
This program is supposed to ask the user to input five words. Then the input is to be sent to a:\. Next the five words are supposed to be brought back with substitutions made to them. It does all of that, but if the user inputs two or more sets of five words, it puts them all on one line. How do I get five words per line, both in a:\ and when it prints them back out on the screen.
while ($quit ne "q"
{
print "Enter any word and return: "; #user input
chomp ($word1=<STDIN>); #Assign input
print "Enter another word and return: "; #user input
chomp ($word2=<STDIN>); #assign input
print "Enter another word and return: "; #user input
chomp ($word3=<STDIN>); #assign input
print "Enter another word and return: "; #user input
chomp ($word4=<STDIN>); #assign input
print "Enter the fifth and final word of this group and return: ";
#user input
chomp ($word5=<STDIN>); #assign input
@words=("$word1", "$word2", "$word3", "$word4", "$word5"
#assign words to array
$wordbreak=(join(", ", @words)); #join words with ,
open(FIVEWORDS, ">>a:\\test2.txt" #send data to a:
print FIVEWORDS $wordbreak;
close(FIVEWORDS);
print "Enter q to quit or press return to enter another group
of five words: "; #quit or continue
chomp ($quit=<STDIN>);
print "Here are the results:\n";
}
open (OLDFILE, "<a:\\test2.txt" #retrieve data
@databack=(split (/, /, <OLDFILE>)); #split data with ,
$_= "@databack";
close(OLDFILE);
s/a/x/ig;
print $_;
<STDIN>;
This program is supposed to ask the user to input five words. Then the input is to be sent to a:\. Next the five words are supposed to be brought back with substitutions made to them. It does all of that, but if the user inputs two or more sets of five words, it puts them all on one line. How do I get five words per line, both in a:\ and when it prints them back out on the screen.
while ($quit ne "q"
{
print "Enter any word and return: "; #user input
chomp ($word1=<STDIN>); #Assign input
print "Enter another word and return: "; #user input
chomp ($word2=<STDIN>); #assign input
print "Enter another word and return: "; #user input
chomp ($word3=<STDIN>); #assign input
print "Enter another word and return: "; #user input
chomp ($word4=<STDIN>); #assign input
print "Enter the fifth and final word of this group and return: ";
#user input
chomp ($word5=<STDIN>); #assign input
@words=("$word1", "$word2", "$word3", "$word4", "$word5"
#assign words to array
$wordbreak=(join(", ", @words)); #join words with ,
open(FIVEWORDS, ">>a:\\test2.txt" #send data to a:
print FIVEWORDS $wordbreak;
close(FIVEWORDS);
print "Enter q to quit or press return to enter another group
of five words: "; #quit or continue
chomp ($quit=<STDIN>);
print "Here are the results:\n";
}
open (OLDFILE, "<a:\\test2.txt" #retrieve data
@databack=(split (/, /, <OLDFILE>)); #split data with ,
$_= "@databack";
close(OLDFILE);
s/a/x/ig;
print $_;
<STDIN>;