Perl, Sed and Awk

Years ago, I learned Sed and Awk to complete a project in telecom. Today, I do not recall any aspect of those languages. But am about to learn Perl and have been told that Perl is based on Sed and Awk.

Is that true?

And how are they similar?

Once I start hearing these details, I suspect I will recall a few things about how and why I used Sed and Awk.

newbiewebSr. Software EngineerAsked:
Who is Participating?
gelonidaConnect With a Mentor Commented:
Perl is a programming language, that was created by Larry Wall who was  fluent in sed / awk /  bourne shell and C programming and has a degree in natural and artificial languages.

He developed Perl's syntax such, that persons knowing sed / awk / bourne-shell and C can learn it rather quickly.

Perl is a very powerful scripting language and has loads of open source modules / enhancements, that will help you to avoid reinventing the wheel.

With few lines of code you can achieve amazing tings.

I still use sometimes sed / awk for one-liners on the command line or within shell scripts.

For anything more complex it is definitely a good idea to use a programming language like Perl or Python.

Perl is easy to learn if you have a sed / awk /  bourne shell / C background.
Python doesn't look that similiar to above languages but is also easy (if not easier) to learn.

I used to write a lot of perl code until about 10 years ago

Since then I switched to Python which has meanwhile a much greater community.
newbiewebSr. Software EngineerAuthor Commented:
Unfortunately, I have forgotten what I once knew about sed and awk, but so far find Perl pretty simple to read.

I also made a major switch about 13 years ago. I moved from C++ to C#, and never looked back. Does Python do all you need?

Are there reasons to use Perl over Python? Or is Python a replacement for Perl?

The description of Perl as the "Swiss Army Hacksaw of scripting languages" seems pretty hard to beat.
wilcoxonConnect With a Mentor Commented:
There is one huge reason to use anything over Python.  Python uses relevant white-space (eg the amount of white-space actually affects the way the program runs).  In college and grad school, I had multiple classes that stressed what a bad idea designing languages in this way is (but Python did it anyway and is inexplicably popular).

As far as I'm aware, there is nothing Python can do that Perl can't except in one niche.  Stackless Python (a specific Python implementation) does not implement a stack which allows some interesting programming tricks (but requires you to work harder to do some other things).
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Dan CraciunConnect With a Mentor IT ConsultantCommented:
Actually, Python code is easier to read because of that relevant white-space.
Back in high school, when I learned Pascal and C, it was common to write several command in one line, forget indentation, etc.
For no reason, just because we could.

wilcoxonConnect With a Mentor Commented:
Python code is only easier to read if the Perl (or Pascal or C) code is poorly written.  You can even run perl code through Perl tidy to make the style uniform if you want (tons of options for what you prefer - unlike Python).
Dan CraciunConnect With a Mentor IT ConsultantCommented:
Yup. C or Pascal code written by a seasoned programmer will be highly readable.

But for beginners, Python forces them to write something that looks like readable code.
wilcoxonConnect With a Mentor Commented:
And Python also makes it so beginners can have a program that looks correct but doesn't run how they expect and can take hours to track down the bug (unless things have changed, tabs and spaces are treated differently in Python so mixing them has disastrous consequences).  This is one of the many reasons that language design courses stress that relevant whitespace is a horrible idea.
wilcoxonConnect With a Mentor Commented:
Also, at least for perl, if you don't find it readable due to the style used, it's as simple as 'perltidy' (which will give you a readable version even without specifying any options).
newbiewebSr. Software EngineerAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.