Welcome to the Monastery | |
PerlMonks |
Re^3: Command Switch -i prints to screen not fileby LanX (Saint) |
on Dec 29, 2020 at 22:36 UTC ( [id://11125953]=note: print w/replies, xml ) | Need Help?? |
Allow me some comments ... I think putting command-line switches into the she-bang is not one of the better ideas, I doubt it's portable. HaukeX just offered an alternative special variable, which even has a full English name $INPLACE_EDIT which is also self documenting. And you've rather got bitten here by the effects of slurping the whole file into an array which is often a dangerous idea, because the size might be huge. I prefer lazy iteration by working line by line, whenever possible. And making a full copy in RAM first is rather the strategy when you intend to directly replace the content in the filesystem, so you somehow doubled the efforts to a paradox effect. Just my 2 cents ... :)
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|