How to remove the certain words using array index for the following input using Perl?

```
file.txt
BOCK:top:blk1
BOCK:block2:blk2
BOCK:test:blk3

```

After join:

```
/BOCK/top/blk1
/BOCK/block2/blk2
/BOCK/test/blk3

```

Expected output: 

```
/BOCK/blk1
/BOCK/blk2
/BOCK/blk3

```

Code which I had tried:

```
use warnings;
use strict;
my @words;
open(my $infile,'<','file.txt') or die $!;
while(<$infile>)
{
    push(@words,split /\:/);
}
my $word=join("/",@words);
print $word;
close ($infile);
foreach my $word(@words)
{
    if($word=~ /(\w+\/\w+\/\w+)/)
    {
        print $word;
    }
}

```