Hi there,
File manupulation is difficult in Perl.
I'd like to modify a file with JSON format.
For example, test.conf is:
- {
-
"tests" : [
-
"test1",
-
"test2",
-
"temp1"
-
],
-
... (and so on)
-
}
And, I'd like to add or delete an item to or from "tests" field.
So I wrote a Perl program:
- #!/usr/bin/perl
-
-
use JSON
-
-
open TEST, ">test.conf"
-
# I have no idea how to get the json data from test.conf to this perl program.
-
# Also, I have no idea how to add or delete an item (e.g. "temp2") to or from "tests" field.
-
# And, I'd like to write the modified filed to test.conf file.
Help please!
Thanks in advance.