How can I do one liner import multiple custom .pm files in my perl script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can I do one liner import multiple custom .pm files in my perl script?
# 1  
Old 04-10-2012
How can I do one liner import multiple custom .pm files in my perl script?

I am new for Perl I want to ask one question. I have around 50 custom packages which i am using in my Perl script. I want to import all .pm packages in my Perl script in an easy way. Right now i have to import each package individually. So Is there any way to do so??

Right Now i am doing like:
Code:
use pack1;
use pack2;
...... 
use pack50;

But I want some easy way Like
Code:
use Pack*;

This is just an example from my way but you can give me any solution.

hey actually i have separate package for single subroutine. I want each subroutine in separate file. So Is there any way that i can keep my each subroutine in separate file. So that i can use all of them in my perl script. ?????

Moderator's Comments:
Mod Comment Please use code tags, thanks!

Last edited by Navrattan Bansa; 04-10-2012 at 06:26 AM.. Reason: code tags, see PM
# 2  
Old 04-10-2012
Hi Navrattan Bansa,

Two suggestions,

First: There are some modules that import many others, like LWP, HTML::TreeBuilder or Mojolicious. Take a look to that point, perhaps you are importing twice some of them.

Second: You can add them to a second file, like 'modules.pl' and execute it from your script like do 'modules.pl'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi I want to replace time stamp in the following line PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read assuming the new time stamp is 09:45 ; the line is getting replaced as below :45 read I'm trying to use the perl one liner in bash script perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies

2. Windows & DOS: Issues & Discussions

how to install custom .bat files in perl

I'm using damke to install perl modules on windows. I have my custom .bat files for the perl script. How to overwrite the .bat files that gets generated by pl2bat with my custom .bat files! Thanks, Hansini (1 Reply)
Discussion started by: hansini
1 Replies

3. Shell Programming and Scripting

how to create custom modules in perl and how to import all modules with single command?

I have some custom functions which i want to use in perl Scripting all time. i want to How to create modules in perl and how to import them. Also if i create 15 modules and i want to > import all at once then how can i import? (0 Replies)
Discussion started by: Navrattan Bansa
0 Replies

4. UNIX for Dummies Questions & Answers

renaming multiple files using sed or awk one liner

hi, I have a directory "test" under which there are 3 files a.txt,b.txt and c.txt. I need to rename those files to a.pl,b.pl and c.pl respectively. is it possible to achieve this in a sed or awk one liner? i have searched but many of them are scripts. I need to do this in a one liner. I... (2 Replies)
Discussion started by: pandeesh
2 Replies

5. Shell Programming and Scripting

Perl one-liner convert to script format problem asking

Input_file_1: ABC1 DEF11 ABC3 DEF7 ABC7 DEF36 Input_file_2: DEF7 light 23 DEF11 over 2 DEF11 over 1 DEF17 blue 0 Perl one-liner that join two input file based on columns sharing a value (In this example, column 2 in Input_file_1 and column 1 in... (3 Replies)
Discussion started by: perl_beginner
3 Replies

6. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

7. Shell Programming and Scripting

perl script on multiple files

I have a script that runs on one file (at a time). like this: $> perl myscript.pl filename > output How can I run it on >6000 files and have the output sent out into slightly modified file name $> perl myscript 6000files> output6000files.new extension Thanks in anticipation (4 Replies)
Discussion started by: aritakum
4 Replies

8. Shell Programming and Scripting

Data Import perl script

Hi, I have a requirement for creating a Perl Script which will perform Data Import process in an automated way and I am elaborating herewith : Section 1 ) - use the following command line format : "./import.pl -h hostname -p port -f datafile.txt" Section 2) datafile.txt will... (3 Replies)
Discussion started by: scott_apc
3 Replies

9. Shell Programming and Scripting

Need help passing variables in shell script to perl one-liner

I'm writing a script to automate some post-install tasks on RHEL4 servers. I need the following code to insert an 'A' in the middle of a string, then replace the string in a file. I know I can use sed to do this, but I'd like to use perl's in place edit so I don't have to write to a temp file,... (1 Reply)
Discussion started by: Xek
1 Replies

10. Shell Programming and Scripting

Combining Multiple files in one in a perl script

All, I want to combine multiple files in one file. Something like what we do on the commad line as follows -> cat file1 file2 file3 > Main_File. Can something like this be done in a perl script very efficiently? Thanks, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question