for ( glob "*.abc" ) { my $old = $_; s/\.abc$/.edf/; rename $old, $_ or warn "can't rename '$old' to '$_'"; }