$_->{$.};s:.?(.)..(.):print(($1..$2)[9,0,15,7]):e
Update:
$_->[/^(?>(.)?(.)+.*)(?!\1)(??{print(($1..$2)[9,0,15,7])})/]


Replies are listed 'Best First'.
Re: small is beautiful
by gaal (Parson) on Feb 26, 2005 at 04:47 UTC
    $_->[s:(.).*.(.):print(($1..$2)[9,0,15,7]):e]
      just another perlgolf

      $$_[s:(.)(.):print+($1..$2)[9,0,15,7]:e]
        print v2.0.3^ref{}
Re: small is beautiful
by Taulmarill (Deacon) on Feb 26, 2005 at 13:24 UTC
    nice, i like it. here is the same but a bit smaller (more beautifull?)

    $$_{0};s:.(.)..(.):print+($1..$2)[9,0,15,7]:e
      Yes, more beautiful :)

      Update: and compilation from all ideas:
      $|[$_->{_,s:.(.).+.(.):print+($1..$2)[9,0,15,7]:e}]


Re: small is beautiful
by Anonymous Monk on Feb 26, 2005 at 05:15 UTC

    Hello Shltn

    Will you please Explain the above Code.

      $_->{$.} # $_ becomes reference to hash # $_ returns HASH(memory address) s:.?(.)..(.): # regex which "captures" 2nd 'A' and 5th '(' symb +ols # '..' range operator returns # ABCDEFGHIJKLMNOPQRSTUVWXYZ # from 'A' to '(' # see perldoc perlop print # 'Prints a string or a list of strings' (($1..$2)[9,0,15,7]) # only 9,0,15,7 array elements are interesting :e # /e modifier which evaluates right side # as an expression


      i'm not 100% shure, but i'll try to explain afaik.
      $_->{$.}
      this only makes $_ a reference to a hash. when accessing $_ via scalar context (as the folloing regex does) you get something like "HASH(0x814cc20)".
      s:.?(.)..(.):print(($1..$2)[9,0,15,7]):e
      this is just a regex substitution with a bit of perlcode in it (the "e" at the end says perl to "Evaluate the right side as an expression.").
      ok, the left side captures "A" and "(" from the string given from a hashref in scalar context (remember?). now the right side generates a list by "A" .. "(" which seems to "realy" generate a list from "A" to "Z" (is this documented somewhere?). from this list the elemnts "[9,0,15,7]" are given to print. thats it!
      easy, hu?