in reply to Re^5: Delete a line from files
in thread Delete a line from files

what is wrong with first opening the file with open and then setting those variables?

Replies are listed 'Best First'.
Re^7: Delete a line from files
by choroba (Cardinal) on Oct 13, 2015 at 10:27 UTC
    It doesn't work. The diamond operator opens the file and reads from it at the same time, you can't first open the file and then set the variable. Check the difference yourself:
    perl -pwe '$^I = ".bak"; s/[<>]/|/g' file1 perl -pwe 'BEGIN { $^I = ".bak" } s/[<>]/|/g' file2
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ