Page 1 of 1

a wordlist in perl without the print command

Posted: 2007-05-07 04:39:41
by js
The manual says that the original dedicated Perl macros are kept for backward compatibility, but you don't need them any more since you can integrate Perl into Nisus Macros. But earlier Nisus Perl macros often used the print command, which is anoutput command. Those earlier dedicated macros would define where the output goes. But how to do that within a Nisus macro? Let's say you have a list of words and you would like to pass this @wordlist on to Nisus as a real list with returns or something as separators. How to do that without the print command?

Posted: 2007-05-07 14:26:33
by martin
You have two options. The first is to pass the word list back as a scalar, eg:

Code: Select all

$str = ''
Begin Perl
    @words = ('red', 'green', 'blue');
    $str = join( "\n", @words );
End
Insert Text $str
Your other option is to use the print statement and simply direct the output to the current document:

Code: Select all

Begin Perl
    #Nisus Macro Block
    #destination front selection
    #End Nisus Macro Block
    @words = ('red', 'green', 'blue');
    $str = join( "\n", @words );
    print $str;
End