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);
In reply to Persistent data storage by ssinha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |