问一个关于字符串操作的问题,谢谢

#!/usr/bin/perl

use strict;
use warnings;

my $test1 = 'c:\test\db\test\next';

my $test2 = substr $test1, 0, 16;

print "[$test1] [$test2]\n";

$test1 = add_slash($test1);
$test2 = add_slash($test2);

print "[$test1] [$test2]\n";


sub add_slash {
        my $t = shift;

        $t =~ s/(.*?)\\?$/$1\\/;

        return $t;
}
多谢楼上的大哥,非常感谢!