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

Thank you for your help.

The code which I am trying to run - what is going wrong in there?? I am a beginner, and it would really help if I know how to modify my code to get the desired output??

Cheers!

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

Replies are listed 'Best First'.
Re^3: Print the data following few specific lines in perl
by BioLion (Curate) on Jul 05, 2010 at 08:02 UTC

    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...