In-place editing of multiple files in a directory using Perl's diamond and in-place edit operator

后端 未结 5 1438
挽巷
挽巷 2021-01-03 05:12

I am trying to in-place edit a bunch of text files using Perl\'s in-place edit operator $^I. I traverse through the directory using the diamond (<>) operator like this:

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 05:51

    You can copy your arguments beforehand, and then use @ARGV. E.g.:

    my @args = @ARGV;
    @ARGV = <*.txt>;
    

    Since there is some hidden processing going on, which is specific to the use of @ARGV and the diamond operator <>, you cannot just use another array to do the same thing.

提交回复
热议问题