I have just started learning perl. I have to write a script that will ask a persons info, ask if you want to add more records, and once it is done print all the info with a : between the fields and a blank space in between records. Here is what I have so far:
The problem I have is that is saves the $first and $last on seperate lines instead of putting them on the same line with a : between them
Code:
#!/usr/bin/perl open(FILE, ">>file.txt"); while (1) { print("First Name "); $first = <STDIN>; print("Last Name "); $last = <STDIN>; print FILE "$first, $last\n"; printf(Add another record? "); chomp($answer = <STDIN>); last if ($answer eq "n" || $answer eq "N"); } close(FILE);
Comment