Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Need help to build a framework

by sriram83.life (Acolyte)
on Feb 24, 2014 at 17:02 UTC ( [id://1076004]=perlquestion: print w/replies, xml ) Need Help??

sriram83.life has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks, I am an intermediate user of perl and am familiar with writing small scripts and perl one-liners. Now, I got a new challenge to build a framework on linux platform,which should extract a .tar file or a .zip or .jar file or a .war file or a .ear file recursively and then find a specific file pattern i give as an input to the framework. For example,in my project i need to find all .SYS2 files,.sys and .swtag files with in the extracted .tar file or a .zip file etc.. Also, i need to find the filenames that contain string i give as input.

This is my approach:

My idea is to build a MAIN script that takes three inputs:

1. my .tar or .zip file as input file.

2. file patterns i need to find inside the archives(.jar or .war or .ear should also be extracted inside the archives recursively to find the .SYS2 file,.sys or .swtag files).

3. string that i need to find inside a file inside the archives.

Add plugin scripts to the main script and call them when needed.

1.write tar.pl to extract tar file

2.write zip.pl to extract zip file

3.write jar.pl to extract jar file

Pass all the extracted files to main script to find files i need and the filename which contains the string i need. A final report should be generated that gives all the file patterns that are found and the file names that contain the string i need. Also, i need to write main.log which should record all the plugin scripts logs with its own logging. Please guide me, it is urgent.

Replies are listed 'Best First'.
Re: Need help to build a framework
by davido (Cardinal) on Feb 24, 2014 at 17:17 UTC

    Which of those steps are you stuck on?


    Dave

      Hi Dave,

      Thanks for the reply.I wrote the main script.But, i am stuck on how to call plugin scripts from the main script and collect the extracted data and logging information from plugin script and dump it in the main script log file.

      Regards,

      Sriram

        Hmm, have you used modules before? Have you written some modules (including for your private use)?

        I did something like this back in 5.6 that required some really funky workarounds. Today I would recommend the following approach (what I did with PGObject's registered type system).

        1. You have a module private (lexically scoped) hash variable connecting an extension to a plugin class name.
        2. You specify an interface for that plugin. We could call it extract_files().
        3. You call it somehow like this:
          "$plugin_registry->{$extension}"->can('extract_files')->($path);

        This approach allows you to add whatever extensions you want and have them register themselves (through an API) which can check for the extract_files interface and add to the registry.

        A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1076004]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found