I would like a Perl Program written that will edit a text file. The program will take as input a text file that consists of a list of items with one item per line. The output file will be a list of database rows that I can then upload to my server. At the beginning of the program code there should be a place for me to specify values for the following:
starting id value (some integer, $starting_id for example)
group category (some char string, $category for example)
parent id value (some integer, $parent_id for example)
EXAMPLE 1: GENERAL CASE OUTPUT
($starting_id, '$first_line', '$category', $parent_id),
($starting_id+1, '$second_line', '$category', $parent_id),
($starting_id+2, '$third_line', '$category', $parent_id),
EXAMPLE 2: SPECIFIC CASE OUTPUT
In this example we will pretend that the input file is as follows:
furthermore we will pretend that at the top of the program I have specified that:
starting_id = 22001
category = "animals"
parent_id = 32
the output should be:
(22001, 'cats', 'animals',32),
(22002, 'dogs', 'animals',32),
(22003, 'pigs', 'animals',32),
(22004, 'kangaroos', 'animals',32),
(22005, 'deer', 'animals',32),
(22006, 'buffalo', 'animals',32),
(22007, 'wild geese', 'animals',32),
you can output this to a text file or edit the input file I really don't care.
Please document your code and make it as clear as possible so that I might be able to understand how it works to edit and expand it in the future. This should be an easy job for the right person who is experienced with perl. I would have to brush up on perl to do it myself.
one more thing is that the program should ignore any white space at the end of a line (but not in the middle of a line such as in "wild geese" above).
Thanks for looking. I look forward to hearing from you if you have experience with perl.