?

Log in

No account? Create an account

it's times like this // life - Lograh — LiveJournal

Thursday, 27.May.2004

11:31 - it's times like this // life

Previous Entry Share Flag Next Entry

it's been forever and a day since I've actually typed up something resembling code. I had forgotten how much fun it can be, to take an idea, identify the tasks that idea encompases, and create a solution to those tasks.

That, and I had forgotten just how precise you have to be! heh..

props to macklinr's 1337 perl skillz for helping me see the (in retrospect, painfully obvious) error in my code.

still, you get moments when you look at the finished code, and see it fly through the tasks like a hot knife through butter, and just admire the compactness and efficiency of typing that accomplishes that.. It's almost poetic, in a way..

if($line =~ /\Q$_\E+\s*([^\r\n]*)/){print "$1,";}

Such a simple line, yet it drives the script that will take a directory full of data dumps and output a file in proper csv format (well, okay, with the exception of an extra comma at the end of each line, but that's easilly ignored) for importing to any spreadsheet program where we can then get an idea for the state of computing in our college. Now all I have to do is write a dos batch file that the users can run from their email to have their machines generate the data files for me (because it's a bitch to run around to each individual computer when you've got a few hundred to do).

For the record, this was my first perl program ever. Yes, I had somehow manged to make it this far in life without learning perl.

Comments:

[User Picture]
From:macklinr
Date:11:53 27.May.2004 (UTC)
(Link)
well, while it's CSV and the extra comma won't matter, here's what I was proposing to remove that.

First, before the while loop:

$dataline = "";

then, instead of: print "$1,";
$dataline .= "$1,";

then after the while loop, instead of just printing a newline:
chop($dataline);
print "$dataline\n";
(Reply) (Thread)
[User Picture]
From:macklinr
Date:12:05 27.May.2004 (UTC)
(Link)
props to macklinr's 1337 perl skillz for helping me see the (in retrospect, painfully obvious) error in my code.

Thanks. But I will point that that it's only painfully obvious if you've been dealing with Regex for a long time.

I should show you some of the nightmare regexs I've written in the past to deal with stuff. I think my longest regex for converting Project Mayhem files was around 200 characters, which involved converting from and older version of this scripting language where I was able to get away with making custom hacks, to the newer version as an official add-on, so I had to do things "by the book".

Frustrating, but in the end it was fun - fun to sit back and watch the file churn out perfectly-executable output. (Well, almost perfect - there were some glitches in the generated code, but they were few and far between, and easy to remedy.)
(Reply) (Thread)