Not quite sure what this is needed for, but the following seems to meet your requirements well enough.
#!/usr/bin/perl
use warnings;
use strict;
my $test = 'doc123/print doc456/read doc789/print doc145/print doc123/
+read';
my %count;
print join '/',
grep {s/^([a-z]+)\s/"$1".(++$count{$1}).' '/ie || $_}
split '/',
$test;
|