Reputation: 119
So I have a script that renames some contents inside a file
local @ARGV = 'myfile';
local $^I = '';
while (<>) {
s/oldtext/newttext/g;
print;
}
Whenever i run it locally on my macbook it works, but when i run it locally on windows using cmd it gives me the following error: Can't do inplace edit without backup at ..
Anyone know how to fix this?
Upvotes: 0
Views: 392
Reputation: 35198
Windows requires that you specify a backup extension.
Just specify a value for $^I
and then optionally delete the backup after processing the file.
local @ARGV = 'myfile';
local $^I = '.bak';
while (<>) {
s/oldtext/newttext/g;
print;
}
unlink "myfile$^I"; # Optionally delete backup
Upvotes: 4