I was only mildly impressed by this until I tried to sort it all out. It's a great one, really quite complex. I think the solution is pretty clear and correct. Nice job xiper.
#!/usr/bin/perl
BEGIN
{
undef $; # $; is $SUBSCRIPT_SEPARATOR
}
$- > new; # $- is $FORMAT_LINES_LEFT
$~ = '10011011001111001110101000000100100011'; # $FORMAT_NAME
$. = '31150460500070422151862305023215186070'; # $INPUT_LINE_NUMBER
unless( $= = 0 ) # just an assignment to $=
# always returns 0 here
{
$_ = ( $. . 9_630_151_829 ); # appends '9630151829' to previous $.
# and assigns to $_
$. = $; # $. is undef now
}
not map # map #1: builds the YAHOP string
{
map # map #2: builds the individual words
{
$* = 2**6; # $MULTILINE_MATCHING
$^ = substr( $~, $_, 6 ); # this grabs various 6-digit strings
# from $~ and stores them in $^
map { $= = $= + $_ } # map #3: $= is undef at the beginning
# of this so it ends up being the
# decimal representation of $^ above
map { $_ * ( $* /= 2 ) } # map #4: converts each bit received
# from the split() to decimal and
# passes the list to map #3
split( $, , $^ ); # $, is undef by default, so it splits
# $^ into its six binary digits and
# returns the list to map #4
$. .= chr( $= + 72 ); # $. is the YAHOP string to be printed
# later; xiper subtracted an offset
# from each of the characters just be
+cause
$= = $; # $= is undef
}
# returns two character chunks of $_ in a list to map #2
# remember that $_ is aliased from down below
/../g;
# $" is a space by default, so insert a space after each word
$. .= $" ##"; # comment
}
# the split returns the five words in their proper numeric format
# to map #1, then it dies
split 6 or die $. . $/ #.+$/g; # comment, not regex
Brandan L.