juldea: (geek girl)
[personal profile] juldea
I want to write a program. I am going to need some help.

So, I use the chat program Trillian at home and at work. Trillian automatically logs conversations for you, which I find to be a very very good thing. However, I am left with a log from home and a log from work... and I'd like to combine them.

Trillian log files are formatted like this:
Session Start (AIM - juldea:RovingFun): Wed Jun 09 16:28:40 2004
[04:28:40] RovingFun: Yar.
[04:31:03] Juldea: *licks your eyeballs*
[04:31:18] RovingFun: ...whoa.
Session Close (RovingFun): Wed Jun 09 17:05:50 2004
So, I'd like to write a program that takes two of these files (either input by me, or the program itself finds the two files that have the same username), filters through them looking for "Session Start" dates, takes the clump of text (string?) between a "Session Start" and a "Session End", and then sorts those strings based on the start dates. Voila, I have one chronologically sorted log file instead of two.

So... This doesn't seem too difficult. I really want to learn what's necessary to write it myself. I took a Java course in college and was really good at it, but it was years ago and I haven't touched anything since then.

What do people suggest? [livejournal.com profile] londo said that if he were to write it, he'd do it in Perl, but that's because he, "loves the Perl." I don't know a thing about Perl... but I've heard multiple times from codin' friends that once you get the basics of one language, the others come fairly easily.

Also - and here's where I'm going to sound like a complete n00b - don't I need a compiler? an interpreter? to write code? In the class I took, everything was provided for us...

I am excited about this. My brain has withered for too long!

on 16 Jul 2004 13:24 (UTC)
Posted by [identity profile] metahacker.livejournal.com
Perl.

It would be dead easy in perl. It would also be dead easy in sh. You can use cat and grep to do this for you...assuming the files are named something chronological and all in the same directory. (cat logfile* | grep -e "^Session" > outputFile, i.e., display all the files starting with "logfile" here, and remove the lines with "Session" at the beginning of the line(^)). But this won't do useful things like keep the *date* in the output; for that you'd need sed or perl, and since perl has completely subsumed sed, go ahead and learn perl...

Perl is an interpreted language. You need the perl executable (on a unix system, type 'which perl' to see if it's installed), but no compiler. Basically you just write perl code in a text file, and then say "perl myFile", and it will execute your code. There are some excellent online tutorials, you can use "man perl" to see the online manuals, or you could pick up a copy of the Camel book (http://www.google.com/search?q=%22camel+book%22).

on 16 Jul 2004 13:50 (UTC)
Posted by [identity profile] juldea.livejournal.com
Each computer only has one file, named "AIM - RovingFun.log" or something like that. Inside the file are many, many instances of what I listed above...

And yes, I want to keep the dates so that I may reference them. Seems like Perl is the way to go. [livejournal.com profile] diego001 has offered me the use of a Perl book he has, I wonder if it's the Camel?

Oh, and I have no access to any Unix Systems, and wouldn't know what to do with them if I did. :P This is something else I badly wish to learn.

on 16 Jul 2004 14:51 (UTC)
Posted by [identity profile] metahacker.livejournal.com
Well, perl will run on almost anything, and you can find those perl man pages online as well as on a unix system...

perl

on 16 Jul 2004 15:36 (UTC)
siderea: (Default)
Posted by [personal profile] siderea
The right language for this sort of thing is perl (or maybe python -- I gather python is a perl competitor.)

You will need a copy of perl. If you're stuck on a PeeCee running Windozw, start googling around to find one. It's free.

Install it.

Then you need to learn to write a perl program. Since, as metahacker pointed out it's an intepreted language, you don't compile your perl program, you ask perl to run it for you.

You will need a texteditor to write your perl program in. I presume Notepad is fine.

This project is pretty simple for someone who knows perl already, but I expect you're are going to find it an enormous big project.

The comment about knowing one language making others easy is wrong. It is only true if they are very similar languages; instead, your first language makes your second language harder. It's only after you've learned several different languages that you understand what is to be abstracted and what is not, from what you have learned from each language.

Perl and Java aren't alike. Perl isn't object oriented. Well, allegedly perl does classes and instances, should you want to use them, but all the OO weenies I have heard from have said perl's OOness is really half-assed. Apparently perl is procedural in its soul.

Re: perl

on 16 Jul 2004 20:24 (UTC)
Posted by [identity profile] juldea.livejournal.com
I am indeed stuck with PCs running Windows, unless someone wants to donate me something else. ;)

I am happy with an enormous big project. It's for me, not a professor or a parent or anyone else. If I slack off, I'm the only one to be disappointed in myself. ;)

Re: the last bit: This will be interesting, then. The class I took focused on the object orientation of Java... so I'll be learning new methods! Hooray! Is it valid to say it will be a different method of thinking?

Re: perl

on 16 Jul 2004 21:02 (UTC)
siderea: (Default)
Posted by [personal profile] siderea
I am indeed stuck with PCs running Windows, unless someone wants to donate me something else. ;)

??? Of course someone wants to donte you something else. Linus and all his buddies. No, not Laenus. The other Linus. The one who wrote a perfectly good operating system with a few friends, and is giving it away.

I am happy with an enormous big project. It's for me, not a professor or a parent or anyone else. If I slack off, I'm the only one to be disappointed in myself. ;)

Good, good. I just wanted to warn you in case having the program soon was more important than learning to write it at all; and also to brace you, and give you a heads up to adjust your expectations.

I found learning perl to be like trying to squeeze my brain through a straw. It still is sometimes, but the straw's much wider (or my brain is much skinnier). :} The reason the beastie on the cover of the relevant O'Reilly book is a camel has to do with the old saw about a camel being a horse designed by committee. Perl, as they say, just grewed, and the result is sometimes really camel-like.

Re: the last bit: This will be interesting, then.

Oh, yeah, and worthwhile. I think perl is a really useful language for what it's good for. I have this love/hate thing going on with perl.

The class I took focused on the object orientation of Java... so I'll be learning new methods!

Nonono, fuctions; methods are OO. :} (Did I just crack an OO joke? I'm such a dweeb.)

Is it valid to say it will be a different method of thinking?

The snarkier OO purists would say that procedural programming doesn't involve thinking at all. :}

More seriously: I think so. I have only passing theoretical acquaintance with Java -- I don't know how people really use it having not read a lot of other people's Java code. I've certainly heard of C++ programmers allegedly doing OO, but really just being procedural programmers who wrap Main around one big hairy procedure. Maybe Java is similar?

I certainly found perl to involve, in some ways, thinking rather differently than I was accustomed to. I would not be surprized to hear it is similarly different, jumping from Java.

Here's the thing which was the biggest weirdness to me: implicit variables (my term). There's all these cases where you don't operate on a specific variable, you just say "Do whatever", and it does it to the implicit variable. So, for instance, you can have the one word statement "print;" and it will -- it will print what's in $_, which is the implicit variable. I gather that in some cases -- important cases, too -- you don't get to use explicit variables at all. For instance, search-and-replace regexps operate (as far as I know) only on the implicit variable.

I found that very disorienting.

At any rate, good luck and have fun. I found being able to do such tasks as you have in mind to be very empowering!

Re: perl

on 17 Jul 2004 03:12 (UTC)
Posted by [identity profile] juldea.livejournal.com
??? Of course someone wants to donte you something else. Linus and all his buddies. No, not Laenus. The other Linus. The one who wrote a perfectly good operating system with a few friends, and is giving it away.

See my comment above... or not, because I'm going to reiterate it all here anyway. ;) I've, much to my disappointment, never even seen any form of Unix being run. I know random abstract things like what a tarball is, but have no practical knowledge about how to operate a Unix system. Therefore I am less than thrilled about the idea of wiping everything familiar off of my computer and replacing it with an OS I don't know how to use. ;)

on 17 Jul 2004 06:14 (UTC)
Posted by [identity profile] alendres.livejournal.com
You could do this with a simple Regular Expression search and replace. :)

on 17 Jul 2004 06:17 (UTC)
Posted by [identity profile] juldea.livejournal.com
Nod, if I knew how to do one of those. ;)

Re: perl

on 17 Jul 2004 19:43 (UTC)
Posted by [identity profile] withlyn.livejournal.com
Never seen any form of Unix being run? Not even when I was running a Linux webserver from your living room?

Re: perl

on 17 Jul 2004 20:04 (UTC)
Posted by [identity profile] juldea.livejournal.com
Ooh, got me there. I guess I have.

December 2012

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated 1 March 2026 22:18
Powered by Dreamwidth Studios