1

I have say 100 custom packages like (file1.pm, file2.pm, file3.pm, file4.pm, file5.pm, file6.pm )

Each file contains one function.

i want to import all in my every simple perl script. How to import them in easy way. Please suggest any easiest way?

3
  • 2
    Sounds like you really should just refactor to put them into logical modules instead of having huge numbers of single function files. Commented Apr 3, 2012 at 12:43
  • Can you give me a simple example of It ????? Commented Apr 3, 2012 at 12:45
  • 3
    A simple example of refactoring some code I can't see, that does something I know nothing about? No. Commented Apr 3, 2012 at 12:46

2 Answers 2

2

You can use this small script to load all 100 modules into it:

# pragma
use strict;
use warnings;

# standard modules needed by the script
use Module::Load;

# the loop below loads all 100 of your custom modules (file1.pm, file2.pm, ...)
foreach my $i (1 .. 100)
{
    load "file$i";
}
Sign up to request clarification or add additional context in comments.

3 Comments

Not Working Saying "String Found where operator expected near "load "file$i"" { Do you need to predeclare load? }
Module::Load does a 'require', not a 'use'. The difference might be important in some cases.
@user970553 Sorry, it's use in lowercase, not in uppercase. I edited my answer. It should work now.
0

As I said in a comment, I think this is a terrible way to organise your codebase. But assuming that you can't do anything about that, you might want to look at the Toolkit module.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.