LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 10-02-2009, 06:58 PM   #16
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244

Quote:
Originally Posted by cmontr View Post
Hello guys,

If you can help, appreciated.

Thanks
you have got a lot of help using awk/perl from your previous posts (since 2 years ago), which are strangely similar to this one. you are still doing ldap stuff and formatting the output. What have you learnt this 2 years since 2007? I would expect you to be very familiar with awk/perl already.
 
Old 10-02-2009, 08:16 PM   #17
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by ghostdog74 View Post
you have got a lot of help using awk/perl from your previous posts (since 2 years ago), which are strangely similar to this one. you are still doing ldap stuff and formatting the output. What have you learnt this 2 years since 2007? I would expect you to be very familiar with awk/perl already.
Since you aren't getting this, I'll explain it to you. Someone figured out they could write a pretty good computer program by asking endless questions in a newsgroup. It's called "programming by newsgroup" and it takes a long, long time.

Programming by newsgroup (PBN) is sort of like throwing a bunch of proteins into a hot salt water bath, coming back in five years, and seeing what's growing. The most advanced PBN projects use a kind of bot that could almost pass the Turing test, but only if the computer side of the test is allowed to sound totally illiterate -- u knw wht i mn?

So a bot asks a question, someone answers, and the bot inserts the suggestion into a disorganized database of code. Then a genetic algorithm churns for a while, comes up with something new, and the process repeats.

Why do you think there are so many people asking questions who clearly cannot type or think? The answer is obvious: they're -- how shall I say this diplomatically -- synthetic people. As people they're a disaster, but as clone-bots, they're quite impressive.

Some of you may think this is fiction, and today, well, yes, it might just be fiction. But tomorrow? Or a week from now?
 
Old 10-05-2009, 08:34 AM   #18
SethsdadtheLinuxer
Member
 
Registered: Jun 2007
Posts: 152

Rep: Reputation: 37
This perl version might do you:
#!/usr/bin/perl
my $filename = "a.txt";
open (my $filein, "<", "$filename") or die "can't open $filename";
open (my $fileout, ">b.txt");
my $lc=0;
while (<$filein>) {
my $x=$_;
$x =~ s/\n/ /x;
$line{$lc}=$x;
$lc++;
if ($lc == 3) {
print $fileout $line{$lc-2},$line{$lc-1},$_;
$lc=0;
}
}
# check for unfinished line
if ($lc > 0) {
for (my $x=1;$x<=$lc;$x++) {
print $fileout $line{$x};
}
print "\n";
}

close $filein;
close $fileout;
exit;
 
Old 10-05-2009, 08:59 AM   #19
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Here is a sed script:
Code:
sed '/dn:/,/created/{ /dn/N
                      /status/N
                      /created/{s/\n/\t/g}
                     }' test.txt
In the range from /dn:/ to /created/, the lines are added to the pattern space. On the last line the newlines are replaced with a tab.
 
Old 10-06-2009, 08:56 AM   #20
SethsdadtheLinuxer
Member
 
Registered: Jun 2007
Posts: 152

Rep: Reputation: 37
This isn't an "improvement", but it does make the sed script produce the "same" output as the original specs
sed '/dn:/,/created/{ /dn/N
/status/N
/created/{s/\n/ /g}
}' test.txt
 
Old 10-15-2009, 03:27 PM   #21
cmontr
Member
 
Registered: Sep 2007
Posts: 175

Original Poster
Rep: Reputation: 15
Thumbs down

Quote:
Originally Posted by lutusp View Post
Since you aren't getting this, I'll explain it to you. Someone figured out they could write a pretty good computer program by asking endless questions in a newsgroup. It's called "programming by newsgroup" and it takes a long, long time.

Programming by newsgroup (PBN) is sort of like throwing a bunch of proteins into a hot salt water bath, coming back in five years, and seeing what's growing. The most advanced PBN projects use a kind of bot that could almost pass the Turing test, but only if the computer side of the test is allowed to sound totally illiterate -- u knw wht i mn?

So a bot asks a question, someone answers, and the bot inserts the suggestion into a disorganized database of code. Then a genetic algorithm churns for a while, comes up with something new, and the process repeats.

Why do you think there are so many people asking questions who clearly cannot type or think? The answer is obvious: they're -- how shall I say this diplomatically -- synthetic people. As people they're a disaster, but as clone-bots, they're quite impressive.

Some of you may think this is fiction, and today, well, yes, it might just be fiction. But tomorrow? Or a week from now?

not too nice!
 
Old 10-16-2009, 09:04 AM   #22
SethsdadtheLinuxer
Member
 
Registered: Jun 2007
Posts: 152

Rep: Reputation: 37
I'll feed the bot to get a "five minute" lesson on perl/awk that doesn't have a deadline attached.
 
  


Reply



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
perl or awk question cmontr Programming 6 09-16-2009 09:36 PM
Shell Script / awk / perl Question cmontr Programming 11 06-25-2008 01:00 PM
awk / perl script help cmontr Programming 3 05-22-2008 04:15 PM
maximum value using perl or awk!! visitnag Linux - Newbie 3 04-11-2008 12:51 PM
Text replacement question: sed/awk/perl whatever BigRedBall Programming 6 02-05-2008 11:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:26 AM.

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
Open Source Consulting | Domain Registration