Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Generic output file

by rajiyengar (Initiate)
on Jan 03, 2014 at 19:42 UTC ( #1069189=perlquestion: print w/ replies, xml ) Need Help??
rajiyengar has asked for the wisdom of the Perl Monks concerning the following question:

We get files from vendors in different format for a product and I want to transform them to one output format. Output file: Ocol1, Ocol2, Ocol3, Ocol4, Ocol5, Ocol6, Ocol7, Ocol8, Ocol9, Ocol10. Vendor files: Vendor1: Vcol1, Vcol2, Vcol3, Vcol4, Vcol5, Vcol6 Source-target mapping: Vcol1->Ocol1 Vcol3->Ocol2 Vcol4->Ocol4 Vcol5->Ocol8 Vendor2: Vcol1, Vcol2, Vcol3, Vcol4, Vcol5, Vcol6, Vcol12, Vcol15 Source-target mapping: Vcol1->Ocol12 Vcol3->Ocol2 Vcol4->Ocol15 Vcol5->Ocol8 I want to define input/output/source-target mapping in config files and want to write a generic perl program that reads the config files and generates output file. In the case of shell script, I can create config files and include them in my script. Would really appreciate some pointers here. Thanks a lot

Comment on Generic output file
Re: Generic output file
by taint (Chaplain) on Jan 03, 2014 at 20:10 UTC
    Based on the title of your question, and the content of your post; I have no idea what the end result of what you're seeking should be. You would probably do well to read How do I post a question effectively?. Have you made any attempt to create your desired output? If so, what did you do? Can we see the product of your previous effort(s)? Your code? ...

    I'm sorry, but without more input from you, rajiyengar. I don't think it's possible to provide a solution.

    λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

Re: Generic output file
by choroba (Abbot) on Jan 03, 2014 at 20:15 UTC
    How is this question different from Creating generic format file? Specifically, you did not get much answers to the old one. What did you do to make the new question easier to answer?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Generic output file
by davido (Archbishop) on Jan 03, 2014 at 20:59 UTC

    Consider how you would do it manually, and then get started working on an automated implementation that follows similar steps. Once you've gotten a good start on it, you can post sample input, sample output, and real code. At that point when or if you get stuck, your question will have the benefit of some code we can look at and help you with.

    When you do post real code, be sure to follow Writeup Formatting Tips.


    Dave

Re: Generic output file
by aitap (Deacon) on Jan 03, 2014 at 21:34 UTC
    The most primitive way is the same as with shell scripts: write your config file in Perl and require (or do) it. You can also use an existing Config-related module or parse your arbitrary config files by hand (see open, I/O Operators, perlretut).
Re: Generic output file
by Laurent_R (Parson) on Jan 03, 2014 at 21:39 UTC
    This is very difficult to understand and I tend to think it has to do, to a large extent, with poor formatting. I also think you should go to Writeup Formatting Tips to figure out how to format your questions, and reformat your post. As it looks now, it is difficult to figure out what is what, and I strongly suspect that you had new lines and other formating devices that became lost.
Re: Generic output file
by boftx (Deacon) on Jan 03, 2014 at 23:47 UTC

    In essence, this really isn't all that different from the topic discussed here just a few days ago. Anytime you start thinking in terms of generic procedures (a Good Thing(tm)) you almost always can follow the tangent that leads to polymorphism and objects. Granted, that might be over-complicating this issue, but it might be a good learning experience.

    It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
Re: Generic output file
by Anonymous Monk on Jan 04, 2014 at 06:13 UTC

    Hi,

    Just a hint, I would probably use pack and unpack to do this.

    But 'there is more than one way to do it'.

    J.C.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-12-17 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (40 votes), past polls