Coding 101

Jul 3rd 2014

Coding 101 24

Perl: Command Line Search and Replace

Learn Search and Replace in Perl.
Records live every Monday at 5:30pm Eastern / 2:30pm Pacific / 21:30 UTC.

The Code for today's show is available at our: Github

Ivory Tower

We learned in the last episode that "Regular Expressions" or "RegEx" is just another way of saying, "find a pattern"

* We learned that we can use RegEx to search a string for that pattern according to a set of parameters and modifiers that WE determine

The usage of RegEx is as Follows:

$nameofstring =~ (Match Operator) / (expression) / (expression) / (Match Expression Operator)

Which means:

$nameofstring =~ (action to take)/(pattern to match)/(pattern to replace match with)/(how to search)

Useful Match Operators

m/ Match Regular Expression

s/ Substitite Regular Expression

tr/ Tranliterate Regular expression

Useful Match Operator Modifiers

g Match globally, find ALL occurences

i case insensitive

m treat string as multiple lines

o Evaluate the expression only once

s treat string as single line

x Use extended regular expressions (Allows you to use white space in the expression)

Get in Touch With Us!

* Subscribe and get Coding 101 automatically at!

* Follow PadreSJ and Snubs on Twitter.

* Watch the show live and join the chatroom every Thursday at 1:30pm PST.

* Email us at and

* Join our Google+ Community!