ssinha has asked for the wisdom of the Perl Monks concerning the following question:
I need to store user inputs using some data structure and then when the code reruns modify the user inputs taken in the previous run. Ive tried storing data in array and then storing the array in a file and then retrieved the array from the file but i am unable to modify the read contents according to my specifications. I am posting what i have done. Please help
arr1=("File1","User1"); @arr2=("File2","User2"); open fin,"+<","arr.txt" or die "error"; print fin "@arr1\n"; print fin "@arr2"; print "Enter filename:"; $fname=<>; close(fin); open fin,"+<","arr.txt" or die "error"; chomp($fname); while($line=<fin>) { print "\nReading"; print "\n$line"; if($line =~ m/$fname\s/) { print "\nEntered if"; chomp($line); print "\n$line"; @read=$line; push(@read,"User3"); $line="@read"; print "\n$line"; print fin "@read"; } } close(fin);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Persistent data storage
by blue_cowdawg (Monsignor) on Aug 16, 2012 at 13:59 UTC | |
by ssinha (Novice) on Aug 17, 2012 at 06:20 UTC | |
by ssinha (Novice) on Aug 17, 2012 at 07:13 UTC | |
by ssinha (Novice) on Aug 17, 2012 at 07:26 UTC | |
by blue_cowdawg (Monsignor) on Aug 21, 2012 at 13:31 UTC | |
|
Re: Persistent data storage
by Athanasius (Archbishop) on Aug 16, 2012 at 13:45 UTC | |
|
Re: Persistent data storage
by flexvault (Monsignor) on Aug 16, 2012 at 13:59 UTC | |
|
Re: Persistent data storage
by locked_user sundialsvc4 (Abbot) on Aug 16, 2012 at 13:11 UTC | |
|
Re: Persistent data storage
by philiprbrenan (Monk) on Aug 29, 2012 at 21:54 UTC |