In article <[EMAIL PROTECTED]>, Mtv Europe <[EMAIL PROTECTED]> writes: > There are some buildin variables that behave not like usual > perl variables since they are represented by some internal fixed form, > like for example $^C and $^H that are bytes. > As mtve realized just after posting this, $^H isn't a byte, but has the interesting property to start at 256 in many circumstances, so it can be used for subtracting:
-p0 $_=reverse,s/\.(?=.{$&}(x.{$&})+o)/*/swhile$-=7890=~/./g (61) There are more of these. Some nice ones: $? is sort of a unsigned short (only sort of since it also can take -1, but $?=-1; --$? gives 65534) $^D and $^P are 20 bits, but are very dangerous since they can start causing STDERR output if perl is compiled for debugging. $^F is a 32-bit value that starts at 2 > So when you modify these vars, their values are bounded by this > internal form. $^C default value is 0, it grows when you increase it > but only until 127. It becomes -128 after that due to sign, > and then increases until 0 again. > > 'something while++$^C' becomes a loop, like in "go" golf > http://terje.perlgolf.org/wsp/pgas/score.pl?func=solution&hole=11&season=0 > The go golf was actually the one where I introduced $^H. At that point I thought $? ($^C was at that point unknown) was unusable there since it would cause an odd number of loops. However, you can hoist the reverse into the while: -p0 s/O(|.{9})[o.]/\l$&/swhile$_=reverse,--$?;y/oO/O./ (which is nice if we ever need to handle bigger boards). Since $? WAS known at that time, in retrospect it's surprising nobody found that. So indeed $^C would actually have been useable there too: -p0 s/O(|.{9})[o.]/\l$&/swhile$_=reverse,--$;y/oO/O./