perl_function
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | perl_function [2006/08/29 20:18] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # $EPIC: perl_function.txt, | ||
+ | ======Synopsis: | ||
+ | $perl(// | ||
+ | |||
+ | ======Purpose: | ||
+ | If EPIC was linked with an embedded perl interpreter, | ||
+ | shall be executed by perl. If EPIC was not linked against perl, then no | ||
+ | action shall take place. | ||
+ | |||
+ | As all //perl statement// | ||
+ | scalar value shall be converted into an ircII string and returned. | ||
+ | means the return value shall not be " | ||
+ | |||
+ | If the //perl statement// has an error, the result is undefined, but usually | ||
+ | an error message is output to the window and the empty string is returned. | ||
+ | |||
+ | Please remember that all function call arguments are subject to ircII | ||
+ | expansion BEFORE the function call occurs. | ||
+ | that are special to both ircII and perl are quoted so ircII doesn' | ||
+ | to honor them. Because //perl statement// | ||
+ | braces, it is best practice to use them. (See examples) | ||
+ | |||
+ | You can call back to EPIC from perl. See [[perl command]] for details. | ||
+ | |||
+ | ======Practical: | ||
+ | $perl() is useful for loading perl scripts and modules, defining | ||
+ | simple perl functions, retrieving variables from within perlspace and | ||
+ | other general maintenance of the perl environment. | ||
+ | |||
+ | ======Returns: | ||
+ | The scalar value of the perl expression. If any other data type is | ||
+ | returned, it will be converted to a scalar under perls rules. | ||
+ | |||
+ | ======Examples: | ||
+ | < | ||
+ | $perl(do script.pl) | ||
+ | See the perl documentation for the " | ||
+ | $perl(use Time:: | ||
+ | Loads the standard perl module Time:: | ||
+ | $perl(localtime-> | ||
+ | | ||
+ | $perl(sub foo {reverse(wantarray ? @_ : " | ||
+ | | ||
+ | its input, whether it is called in scalar or list | ||
+ | | ||
+ | $perl(keys %ENV) | ||
+ | This is because keys returns a list, and $perl() | ||
+ | | ||
+ | the number of elements in the returned list. | ||
+ | $perl(@keys=keys %ENV; " | ||
+ | Since perl lists are scalar when quoted this way, the | ||
+ | names of all environment variables will be returned. | ||
+ | $perl(shift @array) | ||
+ | $perl(push @array," | ||
+ | This will fail, because perl will try to insert a perl | ||
+ | array @host into the string. | ||
+ | nick, user or host contains the quote character used to | ||
+ | quote the string, the expression will also fail. The | ||
+ | | ||
+ | | ||
+ | | ||
+ | $perl($scalar) | ||
+ | perl) variable $scalar. | ||
+ | $perl($$scalar) | ||
+ | $perl({$scalar}) | ||
+ | $perl(`ls`) | ||
+ | $perl(1+2*3) | ||
+ | $perl(" | ||
+ | How to use perl to do regular expression matching on | ||
+ | ircII variables. | ||
+ | </ | ||
+ | |||
+ | ======History: | ||
+ | |||
perl_function.txt · Last modified: 2006/08/29 20:18 by 127.0.0.1