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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello ,

Thanks a lot for your time. To add to my post, my a_copy.txt is something like this:

sjdsajdsd kjfksls'fsaf sandlksadnksalndop djsndsan;sa sdsakdslkdsa sakdsakdsa ..................... ................. NAME|VALUE = a ksadksad dewidewjrw djsdnsalkd dskdsa;dkjsa .................... ............................. TASK|VALUE = copy dsakdmsald;sadsa dsalkdsldk'dls ................................ dskmdsldsdsda CAPS|VALUE = 34 dksdmlsajdsajdsa .............................. dsdksld;sads PKG_TYPE|VALUE = minimal dsmds.dsa.d lsdksadjsldjsdjpos ........................... ............................ .................................. jndlkjsandlksandsndsa jdnsakjdnkjs;dsa kdjslkdjsa;lkds STACK|VALUE = 4 dfdskjff;sdf ............................. ........................ SHIP|VALUE = junk kdskdsakjdl'sa jdsajd;lksahdsakda .......................... dsjads .........................

And input file is user based, so its not confined to only the content you see in my example. It can have multiple values under "NAME|VALUE =" and "TASK|VALUE =" . I have to read these two keywords from the input file, and open the correct (NAME|VALUE)_(TASK|VALUE).txt. In my example, the first one happens to be "a_copy.txt". Second one happens to be "z_cut.test" and third one is "c_paste.txt". There can be many more like this based on the user input. So, I have to grep for the lines that follow "NAME|VALUE = a" and "TASK|VALUE = copy" in the input file, and replace those lines in the .txt file For example, in this case, a_copy.txt, I have to replace the lines "CAPS|VALUE = 34" with "CAPS|VALUE = 0" and "PKG_TYPE|VALUE = minimal" with "PKG_TYPE|VALUE = premium". In the c_paste.txt I have to replace "STACK|VALUE = 65" with "STACK|VALUE = 2" and "SHIP|VALUE = medium" with "SHIP|VALUE = lowtier" and so on. And you are right, since z_cut.txt file doesnt exist, the code has to throw an error in the end giving a list of all the non existent files and exit. The exit should happen only after the code has successfully run on the existing files. For example, post processing , a_copy.txt should look like:

sjdsajdsd kjfksls'fsaf sandlksadnksalndop djsndsan;sa sdsakdslkdsa sakdsakdsa ..................... ................. NAME|VALUE = a ksadksad dewidewjrw djsdnsalkd dskdsa;dkjsa .................... ............................. TASK|VALUE = copy dsakdmsald;sadsa dsalkdsldk'dls ................................ dskmdsldsdsda CAPS|VALUE = 0 dksdmlsajdsajdsa .............................. dsdksld;sads PKG_TYPE|VALUE = premium dsmds.dsa.d lsdksadjsldjsdjpos ........................... ............................ .................................. jndlkjsandlksandsndsa jdnsakjdnkjs;dsa kdjslkdjsa;lkds STACK|VALUE = 4 dfdskjff;sdf ............................. ........................ SHIP|VALUE = junk kdskdsakjdl'sa jdsajd;lksahdsakda .......................... dsjads .........................

In reply to Re^2: Need your help in a pattern based text manipulation algorithm by kaushik9918
in thread Need your help in a pattern based text manipulation algorithm by kaushik9918

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found