in reply to Delete a line from files

Further to AnonyMonk's advice above, also consult perlrun about the effects of the -i, -n and -l flags; they all act to add code around the code you supply on the command line.

Update: E.g.,

c:\@Work\Perl\monks>perl -MO=Deparse,-p -i -n -le "/apple/||print " BEGIN { $^I = ""; } BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined(($_ = <ARGV>))) { chomp($_); (/apple/ or print($_)); } -e syntax OK
See O and B::Deparse.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Delete a line from files
by Anonymous Monk on Oct 12, 2015 at 11:03 UTC
    what is the purpose of the BEGIN blocks?
      "...the purpose of the BEGIN blocks?"

      Begin to read?

      Update: Slight losses are usual in every combat.

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        I meant why set $^I and $^/ at compile time with Begin?