Thanks! Those are much shorter ways of splitting and dealing with the 10s. My method of summing is a bit shorter, so that gets me to 105:

sub bowl { ($_,$n)=@_; s#(\d)(\d|/(?=(.)))|X(?=(..))|.# ($3.$4?"X$3$4":$1.$2,"")[9<$n++]#ge; s#./|X#9#g+map{(3)x$_}/./g } chomp( @ARGV=<DATA> ) if ! @ARGV; for my $line ( @ARGV ) { print "$line = ", bowl($line), "\n "; for( 0..9 ) { print " ",bowl($line,9-$_); } print $/; } __END__ 81633470434/72813/62 81633470434/72813/X18 X00X00X00X00X00 00X00X00X00X00X00 X11X11X11X11X11 11X11X11X11X11X11 5/63XX7043X4/813/6

The |. on the end of the first regex is required so that the regex matches the entire string. Take a 5-frame game as an example:

6/ 45 X 7/ X3/ 14 9 20 20 20 14 23 43 63 83 "6/45X7/X3/" "6/" matches; $1="6", $2="/", $3="4"; change to "X4" "45" matches; $1="4", $2="5"; change to "45" "X" matches; $4="7/"; change to "X7/" "7/" matches; $1="7", $2="/", $3="X"; change to "XX" "X" matches; $4="3/"; change to "X3/" "3" matches; change to "$1$2" eq "" "/" matches; change to "$1$2" eq "" (result: "X445X7/XXX3/")
Those last two substitutions wouldn't happen without the "|." on the end of the regex. The zero-width lookahead assertions, (?=...), aren't part of the "match" and so don't get "consumed" during replacement.

If we required that unused bonus frames be recorded as "-", for example, we could get even shorter. For example, this 86-stroke version:

sub bowl { $_=pop; s#(\d\d|.(/))(?=(.))|X(?=(..))|.#$2.$4?"X$3$4":$1#ge; s#./|X#9#g+map{(7)x$_}/./g } chomp( @ARGV=<DATA> ) if ! @ARGV; for my $line ( @ARGV ) { print "$line = ", bowl($line), $/; } __END__ 81633470434/72813/62-- 81633470434/72813/X18 X00X00X00X00X00-- 00X00X00X00X00X00 X11X11X11X11X11-- 11X11X11X11X11X11 5/63XX7043X4/813/6

        - tye (but my friends call me "Tye")

In reply to (tye)Re4: (Golf) Let's go bowling (105) by tye
in thread (Golf) Let's go bowling by virtualsue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.