User Tools

Site Tools


# $EPIC: perl_function.txt,v 1.3 2006/08/29 18:22:56 sthalik Exp $


$perl(perl statement)


If EPIC was linked with an embedded perl interpreter, the perl statement shall be executed by perl. If EPIC was not linked against perl, then no action shall take place.

As all perl statements resolve to a (perl) scalar value, that (perl) scalar value shall be converted into an ircII string and returned. This means the return value shall not be “binary data” (have embedded nuls)

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. You must ensure that any chars that are special to both ircII and perl are quoted so ircII doesn't try to honor them. Because perl statements can be surrounded by curly braces, it is best practice to use them. (See examples)

You can call back to EPIC from perl. See perl command for details.


$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.


The scalar value of the perl expression. If any other data type is returned, it will be converted to a scalar under perls rules.


$perl(do  Loads and runs
                     See the perl documentation for the "do" function.
$perl(use Time::localtime)
                     Loads the standard perl module Time::localtime.
                     Returns the day of the year from module Time::localtime.
$perl(sub foo {reverse(wantarray ? @_ : "@_")})
                     Defines a perl subroutine which returns the reverse of
                     its input, whether it is called in scalar or list
$perl(keys %ENV)     Returns the number of variables in your environment.
                     This is because keys returns a list, and $perl()
                     returns the scalar value of the expression, which is
                     the number of elements in the returned list.
$perl(@keys=keys %ENV; "@keys")
                     Since perl lists are scalar when quoted this way, the
                     names of all environment variables will be returned.
$perl(shift @array)  Returns the shifted variable.
$perl(push @array,"nick!user@host")
                     This will fail, because perl will try to insert a perl
                     array @host into the string.  Furthermore, if any of
                     nick, user or host contains the quote character used to
                     quote the string, the expression will also fail.  The
                     correct way to do this is to define a subroutine which
                     pushes its arguments onto @array and call it with
                     $perlcall(sub nick!user@host).
$perl($scalar)       Returns the value of the expression in the epic (not
                     perl) variable $scalar.
$perl($$scalar)      Returns the value of the perl scalar variable $scalar.
$perl({$scalar})     Returns the value of the perl scalar variable $scalar.
$perl(`ls`)          How to use perl to get the output of commands.
$perl(1+2*3)         How to use perl to do math.
$perl("$*" =~ /foo.txt/i)
		     How to use perl to do regular expression matching on
		     ircII variables.  Make sure to use double quotes!


perl_function.txt · Last modified: 2006/08/29 20:18 (external edit)