Below is the question I need help on what I have is a program that reads the file prints what is read but I need a way to change what was read and then save it to the file that I opened. The exact wording of the problem is below. I also posted my attempt and work so far I am pretty stuck at the moment.
"write a Perl program that will allow the user to read some data from a file, and then give the user the option of modifying the price of an item, and then store the information back to a file that can be read again later. "
open(FH, "gp1data.txt") || die("Cannot open the file."); print "$_"; while (<FH>){ print "$_"; } my %menu; while (my $line2 = <$prices>) { chomp $line2; my @row = split(/-/, $line2); $menu{$row[0]} = $row[1]; }
The text file says Hamburger - 1.79 Cheeseburger - 2.00 Fries - 1.50
I need to be able to add or change the number of items and prices but I need to store them into a hash after reading the file.
In reply to Hashes and Associative Arrays by phizymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |