Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Print the data following few specific lines in perl

by BioLion (Curate)
on Jul 05, 2010 at 08:02 UTC ( #848025=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Print the data following few specific lines in perl
in thread Print the data following few specific lines in perl

It isn't really a case of right or wrong - you code is doing exactly what you are telling it to - sorting the header lines based on the descriptor field. As you will see all over the place, TIMTOWTDI (there is more than one way to do it) is a core part of Perl programming, so while your method could be made to work, it would be much more complicated than needed (you would need to buffer the squence associated with each header and print them out together, based on testing the header) and ultimately much harder to maintain etc...

Just try to work out (on paper if needs be) what steps you need to achieve, than code each one of those steps - shortcuts/better/different solutions may occur to you as you work, but the important thing is that the code is clear and well documented.

Maybe this doesn't answer your question, but really it is all about practice and experience, so the fact that you have made a good attempt shows that in time you'll be laughing at these sort of problems. Keep plugging away and if you get stuck again, come to the Monastery!

Just a something something...


Comment on Re^3: Print the data following few specific lines in perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://848025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-08-21 16:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls