Views
Perls of Wisdom Camp
Here is a place to share some of your tricks and tips about perl.
Q: I need to change same pattern in a lot of files. I need to change this pattern: https://web to ../../..
A: perl makes this drop dead easy::
perl -pi -e's(https://web)(../../..)g' *.html
-p:print each line
-i:perform an inplace edit
-e:execute the following argument as the command/script
s/target/replacement/flags:search and replace
https//web:the target string (ed: yes i am aware of the lack of a colon. wiki limitation, forgive me) ../../..:the replacement string
g:global replacement, find each occurence on the line.
-john 2003-01-25T01:39:33-0800