#!/usr/bin/env perl use warnings; use strict; use File::Copy; use File::Find; my $dir = '/home/oo/bin'; find( \&wanted, $dir ); sub wanted { return if /^\./; return if -d; if ( -e and -f ) { my $file = $_; my $temp = 'temp_file'; open my $out, '>', $temp or die $!; open my $in, '<', $file or die $!; while ( defined( my $row = <$in> ) ) { $row =~ s|^#!/usr/bin/perl|#!/usr/bin/env perl|; print $out $row; } close $in or die $!; close $out or die $!; move $temp, $file; chmod 0755, $file or die $!; } }