Perl Inline Replacing Perl Script

I am trying to write a perl script with inline replacement. I found this example script for this, but not sure how to use it, since I'm not sure how to specify the file and handler?

$^I = '.bak'  # Call for in-place editing; make backups with a .bak suffix

while (<>) 
{
  s/foo/bar/
  print;
}
+3
source share
1 answer

<> - a special file descriptor.

Special file descriptor: <>

, , < > , , . . , STDIN. UNIX, "-" , STDIN .

$^I - , .

script, , , :

perl yourscript.pl somefile.txt
+4

Source: https://habr.com/ru/post/1781067/


All Articles