in reply to How to prefix a string to all the files in a directories as well subdirectories

I am trying to prefix a string (reference_)to all the *.bmp files in all the directories as well sub directories.

Correct me if I'm wrong, but you want to prefix the name of the files with "reference_", not the files themselves.

I tried open call with '+<' mode but i am getting compilation error for the read and write mode.

opendir(D,"+<$dir1") wouldn't result in a compilation error. It would result in a run-time error because it won't find the directory you named. "+" and "<" aren't even legal characters for directory names in Windows. readdir. You code has other problems, but I won't go into detail since I'm going to recommend that you use File::Find::Rule or similar.

use strict; use warnings; use File::Find::Rule qw( ); use Path::Class qw( file ); for ( File::Find::Rule->name( '*.bmp' ) ->file() ->in( $dir ); ) { my $file = file($_); my $o = $file; my $n = $file->dir()->file( 'reference_' . $file->basename() ); if (-e $n) { warn("$n already exists\n"); next; } if (!rename($o, $n)) { warn("Unable to rename $o: $!\n"); next; } }