Stud_Perl has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Perl Help
by ysth (Canon) on Jun 16, 2005 at 03:08 UTC
    You really need to make an attempt at it and explain what parts you are having difficulty understanding.

    Here's one way not to do it.

    @ops = (" +", " *"); $$_=$| for $ops[$| = 1]; while ((sqrt(@foo)-atan2(0,-1))=~/[^\d.]/) { print "Feed me, Seymour: "; @foo = (splice(@foo, 0), split " ", join("\n", <STDIN> =~ /(?=-?\d).+?(?=\D|\z)/g), $_) for 9-$#foo; } grep {eval(qq!\${"!.$ops[$|--].qq<"}>.$ops[eval '--$|']. qq!=(@{[--$|]},@{[splice(@foo,0,1)]})\n!)} 0..9; print "$_: ", $$_, "\n" for @ops;
    Note that the eval is purposefully insecure and can process unfiltered user input.
Re: Perl Help
by jpeg (Chaplain) on Jun 16, 2005 at 02:36 UTC
Re: Perl Help
by graff (Chancellor) on Jun 16, 2005 at 02:33 UTC
    Hmmm. I'm not sure, but I think you would need to use java or Visual Basic to solve this sort of problem. The perl solution would be too short, and would look like modem line noise.
      while(@_<10){s;;<>;e;push @_,$1 if/(\d+)/}$_=join ' ',@_,$a++; s;(\d+) (\d+);$a*=$1,$b+=$2;ge;print"$a, $b\n";
Re: Perl Help
by merlyn (Sage) on Jun 16, 2005 at 00:37 UTC
Re: Perl Help
by polettix (Vicar) on Jun 16, 2005 at 08:07 UTC
    Please go to the professor and tell them that they gave you incorrect specifications. They define even elements as
    they have subscript values of 2, 4, 6, 8, 10
    but it's not correct! 20 is an even integer, for example, but does not have any of the subscripts in the specs. Maybe you'll want to use this definition:
    they have subscript values of 2, 4, 6, 8, 0
    or better test for oddity using the remainder of an integer division by 2 (see the % operator in perlop).

    I'd also suggest the professor to add "20" to the list of numbers - when you find a bug, add a test to the test suite.

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.
A reply falls below the community's threshold of quality. You may see it by logging in.