Next CSS/Perl question with XPP 9.3

Hello everyone: 

I have encountered my next issue with XPP 9.3, using CSS and Perl. I've created my css using the same name as my style bundle - in this case "basic.css". Then, I created a perl script with a simliar name - "basic.pl", whose package name is also "basic". I originally had this perl file in the library directory for my publication. That works fine. 

However, I'd really like to include some other perl scripts that I've written in the past. Those scripts live in the \xz\perl directory. First, I tried to use statements like 'require' or 'use' to point to those files, but couldn't get that working (not sure when to use those, since I'm a newbie). So that could be part of my problem.

Then, I moved my basic.pl file to the \xz\perl directory, but the compose process can't seem to find it there. 

In the css.pdf document, on page 1-4, it says that the perl file can be in the job directory, the style library directory, or "at the system level". I'm not sure what's meant by that, but I assumed it was \xz\perl. If not, then where should I put this file? Thanks!

Tracey

  • Hi Tracey

    I think that "at system level" would be in Lsyslib under Style Libraries - on our system that would be at \sd_liz\Lsyslib

    That is where "system level" is shown to be in another context in the XyMacros manual (page 2-8)


    Paul


    Paul Montgomery
    Letterpart Ltd
  • Tracey,

    Paul is correct.

    As far as the location of your xyPerl script (= .pl file) is concerned, you can store them at the job, library or at the Lsyslib level. This is exactly the same as any other spec file, except that there is no fallback to something called sys.pl if the file can not be found.

    The xz/perl folder is the place where you would store your scripts (packages?) (= .pm file) that you want to include in your xyPerl scripts.

    The modules you store there can be loaded by a simple 'use xxx;' statement in your xyPerl script.

    I would encourage you to create a subfolder in the xz/perl folder and store your modules there in order to keep them in your own little place and protect them from future clashes with SDL delivered modules.

    If you would call that subfolder something like 'MyModules' and you would store there a module called 'MyFunctions.pm', you would access things from your xyPerl file using:

    use MyModules::MyFunctions;

    (you need to put this after your package declaration and not before it, just like any other module you want to use inside your xyPerl script)

    Note that this will only work with modules, that is in its most simple form a file with a .pm extension and with '1;' as the last statement in the file.

    You can just keep it simple or you can get all fancy by creating yet another package from which you export your additional functions. I would think that in most cases for what we typically do, keeping it simple is already complex enough. You just have to be aware that all you do in your module will live in the same namespace as your xyPerl script. This way things will work just as your added functions from your module would be part of your xyPerl file.

    In short:

    For spec files including the xyPerl .pl files, the system level is the Lsyslib.

    For perl .pm modules the system level is the xz/perl folder.

  • small addendum:
    the use statement will work inside compose as XPP will add the xz/perl folder to the @INC for you.
    If you want to syntax check your xyPerl script, things will fail unless you add the xz/perl folder to @INC yourself.
  • Thanks for all the great information, Bart and Paul. I'm going to do as you suggest, and create a folder for my modules and then try to stay organized.