dcmertens has asked for the wisdom of the Perl Monks concerning the following question:
(Yes, the module is called yX.pm.) However, it'd be really cool if I could just typeperl -MyX my-document.lyx
Perl is pretty flexible, and I thought that maybe I could get away with throwing a few garbage lines at it before getting to the source filter usage line. So, I tried adding something to the LaTeX preamble, resulting in the following sort of stuff at the beginning of the .lyx file:perl my-document.lyx
Unfortunately, perl is not quite liberal enough:#LyX 2.1 created this file. For more info see http://www.lyx.org/ \lyxformat 474 \begin_document \begin_header \textclass article \begin_preamble %ignore; use yX; ...
The astute observer will notice the very top line begins with a hash character. Furthermore, LyX does not examine the content of this line, so I can change it to something like this:Number found where operator expected at test.lyx line 2, near "lyxform +at 474" (Do you need to predeclare lyxformat?) Backslash found where operator expected at test.lyx line 3, near "\" (Missing semicolon on previous line?) Backslash found where operator expected at test.lyx line 4, near "begi +n_document \" (Missing semicolon on previous line?) Backslash found where operator expected at test.lyx line 5, near "begi +n_header \" (Missing semicolon on previous line?) Operator or semicolon missing before %ignore at test.lyx line 7. Ambiguous use of % resolved as operator % at test.lyx line 7. syntax error at test.lyx line 2, near "lyxformat 474" BEGIN not safe after errors--compilation aborted at test.lyx line 7.
Unfortunately, Perl does not let you specify a module in the #! line. :-( Then I struck upon this discussion of the problem on the Perl Porters mailing list. Ric's solution is to use the -d switch, which would look like this:#!perl -MyX
Lo! it works (after renaming the module, of course)! So my question: If I manage to create a module/extension for LyX that adds this shebang line, would I be a horrible person for exploiting this sort of hack?#!perl -d:MyX
|
|---|