Difference between revisions of "Perl"

From Teknologisk videncenter
Jump to: navigation, search
m
m (Search and replace in files)
Line 4: Line 4:
 
== Search and replace in files ==
 
== Search and replace in files ==
 
You could also use find and sed.
 
You could also use find and sed.
<pre>
+
<source lang=cli>
 
perl -pi -w -e 's/SEARCH/REPLACE/g;' *.php
 
perl -pi -w -e 's/SEARCH/REPLACE/g;' *.php
</pre>
+
</source>
 
*e means execute the following line of code.
 
*e means execute the following line of code.
 
*i means edit in-place
 
*i means edit in-place
 
*w write warnings
 
*w write warnings
 
*p loop
 
*p loop
 
+
{{Source cli}}
 
[[Category:Perl]][[Category:Programming]]
 
[[Category:Perl]][[Category:Programming]]

Revision as of 18:14, 18 June 2010

Package wordprocessing.png Under Construction

One liners

Search and replace in files

You could also use find and sed.

perl -pi -w -e 's/SEARCH/REPLACE/g;' *.php
  • e means execute the following line of code.
  • i means edit in-place
  • w write warnings
  • p loop