in reply to Re: rename file extension
in thread rename file extension

Hi thanks for that but I now seem to seeing this other problem again something I have seen before but I guess this is what happens when you have spent almost a year not doing anything with Perl. Help much needed :-) I now see the following error Undefined subroutine &main::fileparse called at testedi line 17 (#1) (F) The subroutine indicated hasn't been defined, or if it was, it has since been undefined. Uncaught exception from user code: Undefined subroutine &main::fileparse called at testedi line 17. I have checked and double checked for mistakes like the one you pointed out, I’m sure it’s going to be something really silly again. Help much needed :-)
#!/usr/bin/perl -w use diagnostics; use Cwd; my $dir = getcwd; my $edihome = "/home/dsadmin/EDI"; opendir(FH, $edihome); @orderlist = grep { !/^\.\.?\z/ && -e "$edihome/$_" } readdir FH; @orderlist = glob "*.tst"; my %ext_map = ( '.tst' => '.test' ); open(FHA, ">renamebatch"); for my $file (@orderlist) { my ($old_filename, undef, $ext) = fileparse($file,qr{\..*}); my $new_ext = $ext_map{$ext} || $ext; my $new_filename = $old_filename; print(FHA "$file\n"); }

Replies are listed 'Best First'.
Re^3: rename file extension
by toolic (Bishop) on Feb 25, 2010 at 13:58 UTC
    Add this:
    use File::Basename;
    And, in the future, wrap your warning/error messages in code tags as well.
      Excellent thanks for this.