Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
There are two sets of values 'A' and 'B'. The code you gave me is considering B set values only. Is there any way I can ask it to look for A first and then move to B.
Almost certainly can. But you need to explain better what 'A' and 'B' are and show some examples of the input files. It sounds as if your data from NEWF have 'A' and 'B' somewhere on each line. 'A' should be replaced by a value from your MYFILE and 'B' should be replaced by a value from SOME_OTHER_FILE. This will be an easy modification if 'A' and 'B' are the last two columns in NEWF. If that is correct, here's how to proceed:

  • Read from SOME_OTHER_FILE exactly as I do from MYFILE, collecting the 'B' values in an array. This assumes that SOME_OTHER_FILE and MYFILE are formatted similarly.
  • Change the while ( <NEWF> ) loop to replace the last two fields with the values you collected from the other two files. HINT: you will use the indices -2 and -1 to access those elements.

I think you should try to write this code yourself. If I made some wrong assumptions, post back with clarification and (most important) samples of the input files and a sample of what the output should look like. I'm quite happy to help you get your work done, but you will learn best if you give it a go on your own and then ask for help if something doesn't work the way you want.


In reply to Re^5: incrementing already existing file by broomduster
in thread incrementing already existing file by wanttoprogram

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 avoiding work at the Monastery: (6)
As of 2024-04-20 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found