in reply to open file and write the content into another file
Replace glob "$folder\*.nfo" with glob "$folder\\*.nfo" so the backslash doesn't disappear.
Replace open my $fh, '<$filename' with open my $fh, '<', $filename because the single quotes in your code don't allow interpolation of the variable. Change the second open similarly. (Thanks to bart for noticing this second error.)
Also, you're overwriting the same output file each time, so in the end you'll only get a copy of one file, the one glob finds last.
If you want to debug such code alone, it could be worth to add a statement like warn "copying ($filename)\n"; to the use_contents function, so that you can see how many times the function gets called and for what files.
|
|---|