fasoli has asked for the wisdom of the Perl Monks concerning the following question:
Hello wise monks,
I'm new here and I'm (captain obvious) new to Perl. Basically I'm a bit confused even about how to describe what I want to do. I obviously don't expect you to hand out ready code for me but more like to help me understand where to look for reading.
So, I am preparing** a bunch of files (let's say 50) by opening them, writing in the file and closing it. However, I need to be able to tell which file is which from their contents - that are just atomic coordinates, so not much help from that. The contents are arranged in columns and the first column is the name of my (chemical) molecule, let's say 1ACx, which goes down for 250 lines. Now I want this x (form 1ACx) to actually be 1 for the whole first file that I'm creating (as in 250 entries of 1AC1), 2 for the second file and so on. So in the end I want to end up with 50 different files, where their first column would go from 1AC1 to 1AC50, but not incrementing in the actual file.
**while I am in a foreach loop, where I am fishing out data from all the files in the foreach loop and saving them in my files.
What I've managed to do so far is a few syntax errors and, mostly, a counter that counts all my atoms, so in each file it goes from 1AC1 to 1AC250. Another thing that I managed to do was print all the lines of the files where I am fishing the data out from.
I honestly can't wrap my head around the concept of how to do it and what it's actually called :( I would be grateful if you could explain it a bit, as in, for example, should I be reading on how to make counters for elements in arrays?
Thank you so much in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: counter of files? something else?
by kennethk (Abbot) on Apr 22, 2015 at 18:24 UTC | |
|
Re: counter of files? something else?
by kcott (Archbishop) on Apr 23, 2015 at 01:06 UTC | |
|
Re: counter of files? something else?
by Marshall (Canon) on Apr 23, 2015 at 02:38 UTC | |
|
Re: counter of files? something else?
by soonix (Chancellor) on Apr 23, 2015 at 07:49 UTC | |
|
Re: counter of files? something else?
by fasoli (Beadle) on Apr 23, 2015 at 11:50 UTC | |
by soonix (Chancellor) on Apr 23, 2015 at 13:19 UTC | |
by fasoli (Beadle) on Apr 23, 2015 at 13:40 UTC | |
by Random_Walk (Prior) on Apr 23, 2015 at 13:29 UTC | |
by fasoli (Beadle) on Apr 23, 2015 at 13:49 UTC | |
|
Re: counter of files? something else?
by fasoli (Beadle) on Apr 23, 2015 at 14:31 UTC |