ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

I have no interest in reconsidering all the circumstances which led to creation of Perl as a replacement for sh/sed/awkk and later transition from Perl 4 to Perl 5 with introduction of references and hierarchical data structures.

I am simply asking you to show how to solve his problem using Perl. I am not asking you to show how good or bad Perl is, or its history. You are simply just a big talker, aren't you.?

Thank you grail. Well, with the given awk commands, I have 4/5 task covered.

good to hear

Quote:

My description of the unsolved task was admittedly vague so I rewrote it in an earlier post. I will work on/copy-past from that cookbook site/get some help with perl programs that do the equivalent.

the equivalent of awk from that cookbook page.

Perl

Code:

while (<>) {
if (/BEGIN PATTERN/ .. /END PATTERN/) {
# line falls between BEGIN and END in the
# text, inclusive.
}
}

awk

Code:

awk '/BEGIN PATTERN/,/END PATTERN/' file

Perl

Code:

while (<>) {
if ($FIRST_LINE_NUM .. $LAST_LINE_NUM) {
# operate only between first and last line, inclusive.
}
}

awk

Code:

awk 'NR>first && NR < last' file

I am just showing you alternatives tools/ways for doing your task. It is up to you to use Perl/Python or whatever you like, but just don't intermix too much of different tools (Perl, awk, etc) in your application because their functions overlap. It will be messy. If you want to do it with Perl/Python/Ruby, then do everything with it.