(each separate char) # The string split into a list of chars map{ ord } # The ordinal value of the char in $_ map{ # uses $b to buffer the 4 bits from the previous # character $\ .= # Append to $\... chr( # the character with ordinal value of 96+( # the 96 ( 01100000 ) that was removed plus $b # the buffered bits from the previous char # stored in $b's 4 high bits (11110000) | # Fill the four low bits with $_ >> 4 & 63 # the four high bits from the current character || 0xc0 # If zero (ie space), use 192 (11000000) instead ) &255 # for space, 192 + 96 = 288 (100100000), so remove # the 9th bit which leaves 32 (00100000) ); $b = # buffer the 4 low bits of $_ as the 4 high bits # $b by: $_<<8>>4 # equiv of $_ << 4 (ie shift $_ left by 4) & 0xf0 # and zero all but bits 5-8 }