All pastes #738450 Raw Edit

gammy

public text v1 · immutable
·published 2007-10-16 10:09 UTC
rendered paste body
# The ugly original. Still smaller than shift method.
sub ed{
    ($o,$d,$e)=@_;
    for(0..length($o)-1){
        $k=$c[$_%@c];
        $e.=chr(ord(substr($o,$_,1))+($d?$k:-$k));
    }   
    return $e;
}   

# An alternative version. It is somewhat prettier I think, but it is still bigger than the original.
sub ed{
    @o=split"",shift;
    ($d,$e)=@_;
    for(0..$#o){
        $k=$c[$_%@c];
        $e.=chr(ord($o[$_])+($d?$k:-$k));
    }
    return $e;
}