in reply to Re: How's your Perl?
in thread How's your Perl?

I had been thinking about 10, but because nobody else bothers to hide their answers, I saw mtye's version already

Note that his version doesn't work under strict, while a strict solution is possible. (the 'official' solution is very different from mtye's), so the exercise isn't spoiled just yet ;-)

Replies are listed 'Best First'.
Re: Re: Re: How's your Perl?
by tilly (Archbishop) on Oct 28, 2003 at 15:36 UTC
    How about an answer for #10 at 24 characters that passes strict?
    use strict; #23456789_123456789_1234 BEGIN{$'y=*x::=*y::=*::} print "Yes\n" if $x::y::x::y::y::x::y::x::x::y::y::y::y::x::y::y;
      bingo :-)

      (it's (a slight variation of) the official solution)

        I don't know about anyone else, but I am stopping here. Problem 1 I know can be done, I have seen the solution, but I remember at the time thinking that I didn't care to know typeglobs well enough to figure that out. Problem 3b I ran afoul of Perl's "return by value" semantics, and I don't know any tricks offhand for that.

        Problem 9 I might be able to do, but I won't. I am guessing is done by something like finding internal variables used for caller, causing the variables to change from eval to eval and between being in an eval and not being in an eval. I don't have enough interest to look up the implementation to find that. (If that approach even works.)

        The bonus question looks like something where I either would need to know the internals better or monitor p5p. Since I do neither, I don't know that.

        Let this be a lesson for those who mistakenly thought that I was some form of a perl deity. As I have said all along, I am far from it. Go bug TimToady, TheDamian, chip, etc if you want to see true Perl mastery.