[PERL] Include .pl file

I needed to use some function to include a .pl file as in C. The answer is: require

mainFile.pl

require "myFunc.pl";

betterPrint("test");

myFunc.pl

push @INC, \&betterPrint;

sub betterPrint {
...
}

Pay attention to what you require. The .pl file must be in the same directory or called through full path.

Lascia un Commento

Fill in your details below or click an icon to log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Log Out / Modifica )

Foto Twitter

You are commenting using your Twitter account. Log Out / Modifica )

Foto di Facebook

You are commenting using your Facebook account. Log Out / Modifica )

Connecting to %s

Follow

Get every new post delivered to your Inbox.