in reply to Re: gathering of some elements of a list
in thread gathering of some elements of a list
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: gathering of some elements of a list
by liverpole (Monsignor) on Jul 30, 2007 at 14:28 UTC | |
Now you're assigning to $file (which doesn't need quotes around it):
Why not use the same variable thereafter?:
But I still think you should specify the exact output you're looking for. I suspect that the solution to get you from input data to output data may be easier than you think, and knowing what output you require will help us to modify your program to generate that output correctly. s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/ | [reply] [d/l] [select] |
by steph_bow (Pilgrim) on Jul 30, 2007 at 14:34 UTC | |
Dear liverpole, Thanks a lot I would like that my outfile looks like :
So that there is a unique column for i, E, and U and if two both appear on the same line, that they are in the same column. (the separator can be "|" or ";") | [reply] [d/l] |
by liverpole (Monsignor) on Jul 30, 2007 at 17:16 UTC | |
Given your output requirements makes things a whole lot easier. For example, you can write a "top-down" program which gives success or failure, depending on whether the computed results match the expected results:
(Note that I added '|' to then end of the last string in the last array, so that line will conform to the same pattern as the others). Now all that's left is to write the subroutines arrays_match, and generate_output. Here is one way:
Above, I've put some diagnostics in arrays_match, to show where the expected vs. computed arrays differ (if they do). I've also created a subroutine transform_line, called by generate_output, which contains the entirety of the parsing algorithm. I think it makes the logic easier to see when it's separated like that, and it makes it easier to rewrite as well (if your requirements should change). Having an algorithm that is as general as possible gives you the added flexibility of working with supersets of the original data, as long as they meet the criteria established in the algorithm. s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/ | [reply] [d/l] [select] |