Three till Seven

Posts with Tag “Perl”

19 Apr 07 a busy day, filled with Perlnanigans

Today was one of those kick-ass days that went by in a whirlwind. I had a discrete math test at 9:30 this morning and I think I did really well on it. It seemed only slightly harder than his last one, which was the easiest test he’d given us. After that, I fiddled in Photoshop on my lunch break, working on another layout idea. At 12:30, I had my algorithms lecture, which was pretty good today because we got help from a geeky computer science grad student on our second programming assignment. Neil was the grad, and he’s also someone I work alongside in Dr. J’s lab. He’s one of those über geeks that just tickle me to death because he’s the type that knows absolutely everything about C, Linux, Perl, math, and computer science theory. People like that are these wonderful fountains of information and I love getting the opportunity to sit down with them and ask random questions about any and everything geeky. My dad’s like that to me with Linux, open source, bash, and old computer hardware, then a coworker at Lexmark was like that with Linux, Perl, and C. I think I admire people like that so much because that’s kind of my goal, to be a 1337 h4×0r with lots of knowledge and skills in such areas.

Okay, away from that little tangent and back to my day. So, after algorithms, I had biology, in which I semi-paid attention to his lecture on the history of life on earth and semi-read Snark. I got to do a little research online for that in order to respond to a post about when one could shoot somebody and have legal recourse based on self defense. My findings (all relevant to U.S. law only) pretty much told me what I already knew: if you feel threatened, you have a right to defend yourself.

After biology, I went to work for two hours, and they were the quickest two hours ever because I got involved in some Perl work. Because of the Apache setup on the machine I have to work on, which doesn’t have mod_perl enabled, I’ve had to split up the app between /var/www/html and /var/www/cgi-bin, with the HTML, PHP, CSS, and images in html/ and the Perl files and modules in cgi-bin/. Today I set up a neat little config file that both the PHP and Perl can parse to determine where to redirect users (/cgi-bin/biodb or just /biodb, based on whether they’re going to a Perl file or a PHP file) as well as other basic options, such as the session name. I’ve got both a testing and a “live” version of the app available, so the two need to not argue with each other over cookies, which use the session name variable, so each needs a different cookie name to peacefully coexist. I love days where I just sit down and code for X hours straight, barely looking up. The time flies by and I leave feeling very productive.

After getting out of work, I immediately came home and started cooking; I fixed shepherd’s pie for mine and Todd’s dinner. I think it turned out very well, even if it did require a bit of work to begin with. Gotta peel the potatoes, get them boiling, brown the beef, mix in the veggies and soups, and then spread everything out in a dish before you can begin to bake it and let it be. I’m more of a ‘toss it in a pan and let it hang out’ kind of girl, but if I have to nurse it to make a great dish, I’ll do it. :) I’ll definitely be making it again, because it was very filling and tasted creamy. Todd and I each had two helpings, too, which was a good indication that the taste was agreeable. I need to recommend it to my mom.

After dinner, Todd and I hit up the grocery, and now I’m relaxing at my place. I figure I’ll play in Photoshop on my Powerbook while my PC updates Ubuntu to Feisty Fawn. It’s going very slowly (I started the upgrade this morning) I imagine because everyone and their mama is upgrading to the latest and greatest. Here’s hoping nothing goes wonky after the update.

Haha, a word popped into my head earlier as a result of my Perl work and because I was thinking about Super Troopers: Perlnanigans. You know, as a play on the word ’shenanigans.’ It’s one of those ridiculous words that are so dumb they make you laugh, or at least it makes me laugh. I can picture some cutesy little image of a person laughing on a t-shirt, with a talk bubble saying, “I’ve been up to some Perlnanigans o noes!!1″, something like that. Hmm, I wonder if Jem would buy such a thing to add to her collection of geeky t-shirts.

13 Apr 07 toilet paper holder engineering and Perl issues

How many engineers does it take to design a toilet paper holder? You wouldn’t think such a seemingly simple device would be difficult, but it’s apparently impossible. Think about it: when you go to a public restroom and there’s the big container of toilet paper rolls in the stall, how often is there just the right amount of friction in pulling off the toilet paper? For me, it’s always one of these two cases:

  1. You have to keep pulling at the toilet paper because it’s stuck, and you just keep ripping off one sheet at a time because the roll barely turns; or
  2. You give a slight tug and you not only get all the toilet paper you need, but there’s also a little pile of it in the floor because there’s no stopping the spinning!

I commented on this to Jess today as we were leaving Macy’s restroom. This is why people like her and I (both in UK’s College of Engineering) have jobs, I tell you.

I’ve hit an annoyance with work, specifically with Perl and sessions. Depending on how I change the application, it requires the user to log in twice before they’re authenticated, it lets them log in once but then going to any restricted area tosses them back to the login screen, or it logs them in on the first try but immediately puts them back at the login page. It’s driving me nuts. I keep thinking I have it fixed and then another permutation of the problem comes up. I didn’t have any of this when I was developing on my Powerbook, on which I’m using mod_perl with Apache. The system it’s on now is in Dr. Jaromczyk’s lab and it doesn’t use mod_perl. I can’t change Apache on that machine because I don’t have permission; I might be able to get the admin to do it, but I want to exhaust other possibilities before doing so. Initially the problem was that the session was getting deleted but the cookie was not. Now the cookie gets deleted on logout as well as the session. Then I thought the problem was that I was setting a cookie path other than ‘/’, the default, so I changed that, but there are still issues. I’ll keep plugging away at it, I guess.

22 Mar 07 using Perl and Apache on OS X

Note: If you enjoy this article, you might also check out the Geeky Stuff section.

I’m trying to do some work with a Perl app on my Powerbook but I was unable to get any Perl scripts to execute from my local server. At first, I was getting just the source of the Perl files spit back at me. I followed a few tutorials about getting /etc/httpd/httpd.conf set up, but then I kept getting 403 Forbidden errors when I tried to access .pl or .cgi files in my browser. I checked /var/log/httpd/error_log and saw:

[Thu Mar 22 10:55:17 2007] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /Users/sarah/Sites/test.cgi

I thought to myself, “B.S.! ExecCGI is on for that directory!” Sure enough, in my httpd.conf file, I had:

<Directory /Users/*/Sites>
    AllowOverride FileInfo AuthConfig Limit
    Options ExecCGI MultiViews Indexes SymLinksIfOwnerMatch Includes
    DirectoryIndex index.htm index.html index.cgi
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

I had restarted Apache with sudo apachectl graceful, so what was up? Then I noticed something else in error_log:

Processing config directory: /private/etc/httpd/users/*.conf
Processing config file: /private/etc/httpd/users/sarah.conf

What was this /private/etc/httpd/users/sarah.conf that it was talking about? I had never created this file. I checked and it certainly existed. It also had an Options line without ExecCGI—bingo! I simply removed the file because it was just redefining what I had already specified in httpd.conf for Users/*/Site directories (shown above). I then restarted Apache and voila, my scripts worked. :) I can only assume something auto-generated that file, because it certainly wasn’t me.

Other things to check if you’re still seeing the source of your scripts or getting a 403 error:

  • Is your script executable? Chmod it to 755 to be sure.
  • Ensure these lines are uncommented in your /etc/httpd/httpd.conf (or whatever your Apache config file is):
    • LoadModule cgi_module libexec/httpd/mod_cgi.so
    • LoadModule perl_module libexec/httpd/libperl.so
    • AddModule mod_cgi.c
    • AddModule mod_perl.c
    • AddHandler cgi-script .cgi .pl
  • Be sure to restart Apache after making any config file changes. You can do this via Terminal with the command sudo apachectl graceful, which will prompt you for your password, or via System Preferences > Sharing, where you Stop “Personal Web Sharing” and Start it again.

« Older entries