#!/usr/bin/env perl use warnings; use strict; use File::Copy; use File::Find; my $dir = '/home/oo/bin'; find( \&wanted, $dir ); sub wanted { my $file = $File::Find::name; if ( -f $file and ! -l $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 or die $!; chmod 0755, $file or die $!; } }