my %skip = (
'gif' => 1,
'jpg' => 1,
'jpeg' => 1,
'png' => 1
);
####
my %skip_for;
@skip_for{qw( gif jpg jpeg png )} = ();
##
##
my ($nil,$ext) = $file =~ /^(.*?)\.(.*?)$/gs;
##
##
my ($ext) = $file =~ /^.*?\.(.*?)$/gs;
##
##
my ($ext) = $file =~ /[.]([^.]+)$/gs;
##
##
#!/usr/bin/perl -w
use strict;
use Fcntl;
use File::Find;
my %skip_for;
@skip_for{qw( gif jpg jpeg png )} = ();
find(
sub {
next if -d or /^[.]/;
next if /[.]([^.]+)$/ and exists $skip_for{$1};
my $content = "";
# gobble and mangle 64k chunks at a time
sysopen FH, $_, O_RDWR;
s/\r//g, $content .= $_ while sysread FH, $_, 65536;
# go back to top of file
sysseek FH, 0, 0;
syswrite FH, $content, length $content;
# the file still has its original length,
# because we didn't clobber it with an open FH, ">file"
# so we need to fix that
truncate FH, tell FH;
close FH;
},
(@ARGV) || "." # NB: parens required
);
##
##
sysopen FH, $_, O_RDWR
or (warn "Couldn't open $File::Find::name: $!\n", return);
s/\r//g, $content .= $_ while (
defined (sysread FH, $_, 65536)
or (warn "Couldn't open $File::Find::name: $!\n", return)
);
##
##
return if -d or /^[.]/;
return if /[.]([^.]+)$/ and exists $skip_for{$1};