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.

Thanks.
newbiewebSr. Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gelonidaCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
wilcoxonCommented:
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).
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Dan CraciunIT 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.

HTH,
Dan
0
wilcoxonCommented:
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).
0
Dan CraciunIT 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.
0
wilcoxonCommented:
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.
0
wilcoxonCommented:
Also, at least for perl, if you don't find it readable due to the style used, it's as simple as 'perltidy script.pl' (which will give you a readable version even without specifying any options).
0
newbiewebSr. Software EngineerAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AWK

From novice to tech pro — start learning today.