cedance has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I am very new to perl. I am learning the basics. However, I am not new to programming.

My task is as follows. I have a ".bib" (bibliography) file for which I have written a parser to make some changes within this file, in perl. This modified .bib file, I have to translate/convert to a .json format from here:

http://simile.mit.edu/babel/

This task is extremely annoying as you have to perform this everytime you modify the .bib file. I just came to know Perl is powerful enough to automate this process. I am a little lost however, in this regard as to where to start. I am not asking you to write the code for me, of course. It would be really great if you could give me some pointers as to how to get started.

best, arun.

Replies are listed 'Best First'.
Re: perl and websites
by james2vegas (Chaplain) on Aug 24, 2009 at 10:07 UTC
    Yes, Perl should be sufficiently powerful to output JSON from your format, seeing as you have it in a parsed format already. Convert your bib format into an equivalent of the format the JSON needs to be in and use one of the JSON modules on CPAN to output it, i.e. a hashref like this:
    { name => 'Sigma 1', publication_date => '1997', pages => [ 3, 4 ] }

    would be return by JSON's to_json function as:
    {"publication_date":"1997","name":"Sigma 1","pages":[3,4]}

    For more details on perl data structures (arrays, hashes, arrayrefs, hashrefs) read perldsc.
      wow, I din't know about existing JSON converters. This is awesome. I don't have to communicate with the website. I will try this and verify the result with the original case. Thank you so much. best, arun.
Re: perl and websites
by $self (Friar) on Aug 24, 2009 at 13:30 UTC
      thank you very much. It might help reduce the code and possibly the runtime too. I have lots of bib-entries and am not so good at using Perl efficiently. It should help a lotttttt!! I see that searching CPAN might give a lot of answers already. thanks again, best, arun.