As you are a beginner, I just wanted to point you to a valuable tool bundled right into perl, Data::Dumper. My pointing this out won't necessarily _solve_ your problem, but it will go a long way towards helping you _visualize_ it.
All you need to do is put use Data::Dumper; in your script. Then you'll be able to use it to display the contents of your variables with a line like:
print Dumper( $foo );
So, you might use it in your script to display your @s array, or within your foreach loop to show the current value of your $line variable.
Keep Data::Dumper in mind. It's helped me learn all sorts of things in perl because it makes it so easy to actually see what's happening in a script.
--
naChoZ
Therapy is expensive. Popping bubble wrap is cheap. You choose.
| [reply] [d/l] [select] |
i get: "Use of uninitialized value in concatenation (.) or string at 8.pl line 22"
... the file ... is not a table but arranged in 8 columns separated by space...
So, if you used the code as I posted it on the file that you describe, then yes, you would get that message about line 22 (the "print" statement) and no other output, because the split was based on /\t/ (as you had it in your original post), and with no tabs in the file, nothing would be assigned to $type. I gather you've gotten past that problem, and are moving on to the real job.
But the rest of your description of the job is hard to follow. If you are having trouble working it out, you'll need to show us some sample data that will make it clear what you are trying to do. If you are using two or more input files, and trying to relate information across the files to get specific outputs, show us a few relevant lines from each input, and what the corresponding output should look like. Then show us the code you've tried so far.
(Now that you've gotten past the issue of "splitting a table into individual columns", you might want this new information and question, about joining data from different inputs, to be the start of a new thread.)
| [reply] [d/l] |
Thank you again for bothering with me, i don't know anyone, who knows Perl and i have an assignment to do. i don't know what are the rules of what's acceptable with asking questions on the fora... but I'm getting stuck on small things and can't move forward with bigger ones.
I've managed to move pass this problem, but not much further than that.. as i was trying to organise other bits of my assignment. therefore i have a question, when you were a beginner, how did you cope, saved/organised your files? i've just realised that i have tones of files to go through at different stags of development and what worst, i've actually lost some bits, that were working... i find it so demoralising and would appreciate any helpful tips.
thanks for now - will be back when next problem arises ... i.e. 5 min :)
| [reply] |
Don't be so hard on yourself, and don't panic. And don't get so wrapped up in self-pity that you ignore the suggestions being given. Programming is an intrinsically detail-oriented activity, so "getting stuck on little things" is a never-ending aspect of the job. Get used to it, and work on your skills for diagnosing, experimenting, and "reading the f***ing manual".
(Yes, it is okay, and in fact highly recommended, to take an experimental approach to the questions and problems that come up when trying to write a program. It's the best way to learn, especially in areas where the documentation seems confusing or incomplete to you. Try things out and see what happens.)
Don't just complain in general terms about how you aren't getting anywhere, because you can't get anywhere that way. Address the specific details that get in your way, and if you can't get past a particular problem, back up and look for another approach for accomplishing the overall task.
| [reply] |