10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
13 map "$PROGRAM_DIR$_",qw{modules lib
../modules
..lib
};
17 my @OPTIONS = qw
/help|h|? version|ver edit-me manual|man/;
22 require MyPlace
::Usage
;
23 Getopt
::Long
::GetOptions
(\
%OPTS,@OPTIONS);
24 MyPlace
::Usage
::Process
(\
%OPTS,$VERSION);
28 require MyPlace
::Usage
;
29 MyPlace
::Usage
::PrintHelp
();
32 die("Invalid Usage\n") unless(@ARGV);
33 foreach my $org_filename (@ARGV)
37 if(open FI
,"<",$org_filename)
52 my $dirname = $org_filename;
53 if($dirname =~ m/^(.*)\.([^\.]+)$/)
58 if($dirname =~ /^(.+)\/[^\
/]*$/) {
64 my $new_name = "$dirname$new_basename$ext_name";
65 if($new_name eq $org_filename)
67 print STDERR
"$org_filename: New name is the same as orginal name\n";
72 print STDERR
"Rename $org_filename to $new_name\n";
73 system("mv","-v","--",$org_filename,$new_name) unless($OPTS{'--test'});
78 print STDERR
"$org_filename MAYBE NOT contains any NON-EMPTY line\n";
79 print STDERR
"$org_filename Skipped.\n";
88 print STDERR
"File not accessible : $org_filename\n";
98 rename_by_firstline - rename files according to the FIRST NON-EMPTY LINE
102 rename_by_firstline [options] file1 [file2...]
110 Print version infomation.
112 =item B<-h>,B<--help>
114 Print a brief help message and exits.
116 =item B<--manual>,B<--man>
118 View application manual
122 Invoke 'editor' against the source
126 Do not perform renaming action
132 rename files according to the FIRST NON-EMPTY LINE
136 2010-06-08 xiaoranzzz <xiaoranzzz@myplace.hell>
142 xiaoranzzz <xiaoranzzz@myplace.hell>