in reply to New student, can we write this program in perl...

I would use grep and the % operator. Could also do it with the ternary operator and the % operator (although that is approaching too cute to maintain).

Update: based on other provided information in this thread, you may also want to see print, join, say, and chomp.

--MidLifeXis

  • Comment on Re: New student, can we write this program in perl...

Replies are listed 'Best First'.
Re^2: New student, can we write this program in perl...
by rahulraina7 (Initiate) on Oct 19, 2012 at 16:52 UTC
    how do i input array of n numbers in perl sir ..?

      my @data = <> would be one way. Could always read one line at a time with while (<>) {...}. This is stuff that you or your instructor should have already covered in your course, isn't it?

      Update: if not, take a look at perlintro, perlfaq, perlsyn, perldata, and so on.

      --MidLifeXis

        In india we do have to do lots of research work like this, blame it to the poor teaching system.