Perl – How to re-use available sub ?

U have some already written sub that wanted to re-use? Here is what u should do :
(Unluckily I’ve forgotten how I found this, but still the way how then 🙂 What a pity!)

At the begging of your Perl script, u add the line :

use lib "/pathTo/YourLibsFolder" ;
use yourTheLibFile_uWannaUse ;#this file must return 1 at the end!

From this point and below, u can use all the sub stored in the above file simply just by calling the sub itself!

I myself find this extremely helpful when in Perl no writeline function is available, we have to : print "something…","\n", i.e manually add the new-line charater by ourselves which is a very bothering thing to do!

Have fun with the lib!!!


Leave a Reply

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

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

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

Facebook photo

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


Connecting to %s

%d bloggers like this: