To answer some of the previous posts regarding Perl..
The first argument to a method in Perl is a reference to the receiver (self). That's why the code is operating on $_[1].
The $_[1] = '...' thing is setting the value of the parameter 1 passed to the method. This is how functions like chomp() work.
For instance you can say:
my $var = "some text\n";
chomp( $var );
And $var will be chomped afterwards because chomp operated on the reference. So for some reason the original author decided that was the way his methods would work.
Of course nobody can explain the reason the code is so complex except the original author.. ;-)
B