Operating System - HP-UX
1752815 Members
6260 Online
108789 Solutions
New Discussion юеВ

Re: Which came first, the sed & awk or the Perl?

 
SOLVED
Go to solution
Ian Dennison_1
Honored Contributor

Re: Which came first, the sed & awk or the Perl?

Having been a code cutter before a SA, I prefer awk and sed myself.

I think it depends what you are likely to be exposed to on a regular basis and how you think; Perl is obviously the up-and-coming environment, but I find awk and sed suit my programming style and experience (4GLs, old 80's programming training, COBOL, etc).

Ask yourself this question, which of these loops would be the way you would mentally structure the problem?

Answer A:

While not EOF
Read from File
count++

End Loop
Print Count

Answer B:

Print File, pass to a function that counts the lines and prints the result

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


Answer A:- Use Perl

Answer B:- Use awk / sed

I will try to come up with a better test and will post it later. Share and Enjoy! Ian
Building a dumber user
malay boy
Trusted Contributor

Re: Which came first, the sed & awk or the Perl?

Hi guy's
I'll be trying to read perl book(O reilly) starting from last week but no avail.By starting looking at the book, is as though as taking a sleeping pil.

Tip:Get a lot of coffee...

regards
mB
There are three person in my team-Me ,myself and I.
Jim Mallett
Honored Contributor

Re: Which came first, the sed & awk or the Perl?

Thanks all, some interesting replies! I owed Clay for straightening me out on an earlier post so he got the bunny. I'll eventually get thru all the books, I just wasn't sure if there was a logical step to them.
I'm going to go with the Perl first because I still do a lot of Windowz work and I like the idea of it being cross-platform.

For all in the States, have a Happy 4th! For all that aren't, I guess have a Happy 4th without the fireworks.

Jim
Hindsight is 20/20
Graham Cameron_1
Honored Contributor

Re: Which came first, the sed & awk or the Perl?

Clay and the others are right, you can do everything in Perl without having to touch any of the others.
The big problem I have with Perl is that is is write-only, especially the REs. It is so powerful that scripters get carried away and can generate complex code that may have been obvious to them at the time are completely incomprehensible to anyone else.
sh, awk, sed etc may have less power and take longer to write (and run), but readability is something I have never had a problem with.

BTW don't forget us in the UK when dishing out points. Being to your East we generally don't get to post replies until the day after, by which time all the easy points habe been scooped up ;-(

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Umapathy S
Honored Contributor

Re: Which came first, the sed & awk or the Perl?

Jim,
I missed the bandwagon. Hope to join late will not be punished.

My idea is to start with sed and awk first. That will give an edge with the shell script background. Oneliners will come in handy as always. Master regular expressions also. Get Oreilly Mastering regular expressions also. You can move ahead in Perl quicky if you have these basics. Actually you can concentrated on Perls richness. A lot of coffee is needed (I drink tea).

Good with cygwin. Cygwin is where I actually learnt all these stuff. Learning and doing some samples wont be a problem in cygwin environment. As also you can update the cygwin to the latest one. The trick will be the usage of regular expressions. If we master that then done.

All the best for a successful weekend. (Get the camel at the end. But you need to practise before reaching there.)

cheers
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
John Bolene
Honored Contributor

Re: Which came first, the sed & awk or the Perl?

Yes Perl can be very hard to understand if you use all the assumptions, defaults, and syntax, once you get there you will understand what I am saying.

There is a one liner contest where you have to make it as hard to understand as possible while doing something worthwhile.
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
Fred Martin_1
Valued Contributor

Re: Which came first, the sed & awk or the Perl?

I don't think you can be a unix system administrator and not know sed/awk. I regard those as basics. Don't know about the others but you should get the book "The AWK Programming Language" by Aho, Kernighan and Weinberger (the authors of AWK). It's the shortest most consise and most useful manual on the face of the earth.
fmartin@applicatorssales.com
Edgar Avila
Frequent Advisor

Re: Which came first, the sed & awk or the Perl?

Definitly PERL.
Why?
You have all the modules you need at www.cpan.org. EVERYTHING.
Modules for databases, for networking , even to emulate a subset of expect.
It's a glue languaje. That means you can use it to comunicate in some way betwen apps.
You can do CGIs.
Emulate ASPs.
Any trouble you can have, perl has a solution to it. Easy (well... most of the times).
If someday you need something of awk or sed, you can use:
# my_command | perl -ne 'you litle script here'.

And don't even think about it.
Learn Perl, and learn it well.
I've been developing Network Management Apps for 4 years. Perl always has been the solution of all my headaches.
Knowledge is power... so... give me the power!!