# You don't have a file named $concat yet. &modified_file($concat); rename($orig, $concat) || print "error can't rename $orig to $concat: $!"; #try switching the order: rename($orig, $concat) || print "error can't rename $orig to $concat: $!"; &modified_file($concat);