Perl

Fun with dead languages

I missed DemoCamp7 last night, which had me kind of bummed (true geek story: I was working all day on a laptop that was set to the wrong time zone, then wondered why I was feeling so hungry at only 5:30, when it was really 7:30…), mostly because Damian Conway was going to be presenting some Perl stuff, and then I saw this post on The Farm, which at first I thought was just a report on last night’s fun, but sweet mother of, well, whatever, Damian was giving a talk tonight!

After seeing Fun With Dead Languages, big one sentence paragraphs are all I’m capable of.   It’s been a long time since I’ve been so entertained while someone demonstrates how very smart he is.  OK, that was a 2 sentence paragraph.  Now 3.  Now 4.  Urg, need recursion.

Technorati Tags:

General
Perl
Programming

Comments (0)

Permalink

Harsh reminders: Ampersands and System()

Filed under “whoops”:

I wanted to look for a resource leak in one of my apps, but didn’t want to bother installing (and learning) some load test utility (which I really need to do, but not this morning). I made a quickie perl script:

NOTE: there should be semicolons after the system calls, but WordPress is returning error 503 if I do that. I’ll have to look into it later (between the “no image uploads from ecto” bug in 2.0.1 and this error in (I’m guessing) 2.0.2, I’m really loving WP right now…)

while($counter++ < 50000)
{
print $counter . “\n”;
system(”curl http://url.com > /dev/null”)
}

Unfortunately, my URL had parameters:

while($counter++ < 50000)
{
print $counter . “\n”;
system(”curl http://url.com&x=5 > /dev/null”)
}

It only took a second after I ran it to realize that I’d just spawned hundreds (growing into thousands) of requests with the ampersand being interpreted as “run in the background,” which was good for load I suppose, but not good for a lot of other things.

Proper code:

while($counter++ < 50000)
{
print $counter . “\n”;
system(”curl http://url.com\\&x=5 > /dev/null”)
}

And yes, my first run only had a single backslash, which was ignored as an invalid escape sequence. Urgh.

Now if I could just recreate the leak…

Technorati Tags: , ,

Perl

Comments (2)

Permalink