phizymonk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hashes and Associative Arrays
by GrandFather (Saint) on Jan 27, 2016 at 02:50 UTC | |
by phizymonk (Novice) on Jan 27, 2016 at 03:12 UTC | |
by GrandFather (Saint) on Jan 27, 2016 at 03:33 UTC | |
by phizymonk (Novice) on Jan 27, 2016 at 03:38 UTC | |
by GrandFather (Saint) on Jan 27, 2016 at 04:11 UTC | |
|
Re: Hashes and Associative Arrays -- modify an array given user input
by Discipulus (Canon) on Jan 27, 2016 at 12:18 UTC |