in reply to Re: Simple Perl, to get me started.
in thread Simple Perl, to get me started.

Thanks for the working code, is there a way to do the same job without these new things, like use strict and use warnings and sort? The code before has no mension of these, so im thinking how out of thin air was I meant to have known these from the past codes.

Replies are listed 'Best First'.
Re^3: Simple Perl, to get me started.
by marto (Cardinal) on Oct 27, 2010 at 16:01 UTC

      For an analogy:
      You got this one recipe that needs adjusting from an eccentric guy with only a poofy hat and a spatula...

      use strict; # Like wearing pants in the kitchen use warnings; # Shirts are good when the boiling grease is flying too

Re^3: Simple Perl, to get me started.
by ig (Vicar) on Oct 27, 2010 at 17:00 UTC

    The problem can't be solved with only the functions and operators in the code you were asked to review - you must use something else. I can't tell you what the author of the lab your are studying intended, but learning to think and research independently will be more valuable in the long term than the Perl you will learn.

    Sometimes it is helpful to try to solve a problem with a limited set of tools and sometimes this is required in an academic assignment. If it is, it should be obvious and you should try to solve the problem with the restrictions. Even outside the academic environment you will find yourself limited by seemingly arbitrary and poorly informed decisions of others. Otherwise, there is rarely a restriction on the research and learning you can do, other than the number of hours in the day. Others have pointed out resources available here and elsewhere on the Internet. There are excellent books available. The initiative to find them and learn is yours.

Re^3: Simple Perl, to get me started.
by toolic (Bishop) on Oct 27, 2010 at 17:41 UTC
    is there a way to do the same job without these new things, like use strict and use warnings
    Yes, but you will regret it... The strictures, according to Seuss
    and sort?
    You don't have to use the Perl built-in sort function. You are at liberty to determine the maximum length with your own code. I just showed you one common way to do it.