LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-24-2010, 08:47 PM   #61
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,692

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987

Well let us know how you get on
 
Old 08-24-2010, 10:04 PM   #62
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by Sergei Steshenko View Post
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.?
 
Old 08-24-2010, 10:12 PM   #63
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by Feynman View Post
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.

Last edited by ghostdog74; 08-24-2010 at 10:19 PM.
 
  


Reply

Tags
data, file, parse, string, text


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extracting lines from very large data files lothario Linux - Software 1 12-15-2009 10:22 PM
AWK/Perl for extracting data from txt file to numerous other files briana.paige Linux - Newbie 2 05-05-2009 10:53 AM
Extracting ASCII strings from a Binary files poorrej Linux - Newbie 2 10-31-2008 04:38 AM
extracting data from html files into one text file adityavpratap Slackware 9 05-10-2007 11:30 AM
Extracting MySQL data from raw files cs-cam Linux - Software 1 06-13-2006 12:22 AM


All times are GMT -5. The time now is 03:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration