Download the file
  1. #!/usr/bin/perl
  2.  
  3. $track_no = 0;
  4. while(<>) {
  5. $track_no ++ if /^TRACK AUDIO/;
  6. if ($track_no > 0) {
  7. $tracks[$track_no-1]->{title} = $1 if /TITLE "(.*)"/;
  8. $tracks[$track_no-1]->{composer} = $1 if /COMPOSER "(.*)"/;
  9. }
  10. else {
  11. $title = $1 if /TITLE "(.*)"/;
  12. $composer = $1 if /COMPOSER "(.*)"/;
  13. }
  14. }
  15.  
  16. sub latex_escape {
  17. my $s = shift(@_);
  18. $s =~ s/\&/\\&/;
  19. return $s;
  20. }
  21.  
  22. print '\documentclass{audiocd}
  23.  
  24. \title{'.$title.'}
  25. \begin{document}
  26. \begin{content}
  27. \begin{tabular}{r@{ -- }p{11.7cm}}
  28. \small
  29. ';
  30.  
  31. for (my $i = 0; $i<=$#tracks; $i++) {
  32. printf "%d \& \\textit{%s}, %s\\\\\n", $i+1 ,
  33. &latex_escape($tracks[$i]->{title}), &latex_escape($tracks[$i]->{composer});
  34. }
  35. print '\end{tabular}
  36. \end{content}
  37. \end{document}
  38. ';
  39.  
  40.