portability of (perl) macros
Posted: 2010-01-28 01:01:46
I am trying to write a macro to transform a file. Since I would like this macro to have some degree of portability (i.e. be usable independent of Nisus Writer) I have chosen to write the macro in perl. This works fine for me since perl macros run in Nisus as well.
However the following issues have come up.
The basic structure of the macro is like this:
That is, I use a while-loop to read the data in, and print to return the output. This works fine except for one issue. To get this to work in Nisus I need to use "<STDIN>", but when I use Textwrangler I need to use the diamond operator ("<>") instead. Can anybody explain why there is this difference? Why doesn't the diamond operator work in Nisus? (or why doesn't STDIN work in Textwrangler?). Alternately is there any way to write this so it works in both without change?
And one more thing, is it possible to run such a macro on a file without using Nisus (or Textwrangler)? That is, can I run this directly on the mac? (in terminal?) Is it perhaps necessary (preferable?) to write some more specific input/output specifications. Again if this is necessary, is it possible to write it in such a way that the macro still works from within Nisus as well?
Any help appreciated.
Philip
However the following issues have come up.
The basic structure of the macro is like this:
Code: Select all
#!/usr/bin/perl -w
…
while (<STDIN>) {
…
print $myOutput, "\n";
…
And one more thing, is it possible to run such a macro on a file without using Nisus (or Textwrangler)? That is, can I run this directly on the mac? (in terminal?) Is it perhaps necessary (preferable?) to write some more specific input/output specifications. Again if this is necessary, is it possible to write it in such a way that the macro still works from within Nisus as well?
Any help appreciated.
Philip