2

I used a Bibtex to HTML Perl converter to parse a bibtex entry file and create an HTML file with a table to be displayed on a website containing the bibtex entries.

The problem is the HTML output file is sorted in the same way the bibtex was sorted, from older to newer dates, and I need to change the order of the html table elements based on the publish year which is not an entry in a row itself

example:

<tr>
<td class="publink">

<a href="blabla">html</a><br/>

<a href="blabla">pdf (ams)</a><br/>

<a href="blabla">pdf</a></td>

<td class="pubname">

<b><a href="blabla">STOCHASTISCHE MODELLE F&Uuml;R DIE BETRIEBLICHE PLANUNG</a></b>   <br/>

<a href="blabla">R.  Hilfer</a><br/>

<a href="blabla">GBI -- Verlag, M&uuml;nchen, 1985</a></td>   </tr>

 <tr>

Here i simply want to sort with the year so extract this 1985 and all other years in the other entries and sort that from the file to create a new and sorted html file..

I hope someone can give me any suggestions!

Thanks!

Mariam H
  • 171
  • 1
  • 3
  • 11
  • Which module or program did you use to convert your file? Do you have access to single parts of the HTML (node-objects, lines)? Have you already tried something? If yes, please post what you've got. – simbabque Apr 30 '12 at 15:55
  • I am using this module from CPAN [link](http://search.cpan.org/~gerhard/BibTeX-Parser-0.64/) My output is a very simple html table, the only problem is that the table is sorted in the same order the bibtex was sorted, which is from oldest to newest, I just want to resort according to the year as i explained in the table entry above.. Thank you very much! I am new to this! – Mariam H May 01 '12 at 09:49
  • Just post your code. We'll be able to help then. – simbabque May 02 '12 at 07:20
  • @simbabque, This is my sorting code taken from what @Kenosis suggested: `local $/=undef; open(FILE, $ARGV[0]) or die "Couldn't open file: $!"; binmode FILE; my $html = ; open (OUTFILE, ">>sorted.html") || die "Can't oupen output file.\n"; map{print OUTFILE "$_->[0]"} sort{$b->[1] <=> $a->[1]} map{[$_, m|, +(\d{4}).*|]} $html =~ m|(.*?)|gs;` The output comes out semi-sorted. Links: Input html:[link](https://docs.google.com/open?id=0BxHnPTcuqJVmb1BQR19RWVJzMnM) Ouput: [link](https://docs.google.com/open?id=0BxHnPTcuqJVmbWZzNi0tMlVZZkk) Thanks a lot! – Mariam H May 02 '12 at 08:03
  • I reposted and reformatted the question here: http://stackoverflow.com/questions/10410004/html-sorting-with-perl-regex Thanks alot again! – Mariam H May 02 '12 at 08:27

0 Answers0