Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

statico (5018)

AOL IM: eisforian (Add Buddy, Send Message)


Co-author of Perl Testing: A Developer's Notebook []

Journal of statico (5018)

Monday April 26, 2004
11:07 PM

perl saves the day! (kind of a seabuscuit thing)

[ #18504 ]

One-half of the College (including faculty and grad students and entire labs) is about to move into the new building. Your job is to make sure a shiny new CAT-6 cable is plugged into the proper wall port so that they can unpack, plug their machine(s) in and go. This requires plugging the right-length cable into the right jack with the right VLAN, and then making notes if the VLAN has to be changed from the defaults in case, say, they have three Solaris machines instead of just one.

Most of the lab coordinators were nice and gave you a list of everyone in their new lab space and where they're going to be sitting, so you checked with them beforehand and determined what machines they have. Your only resources are your old host database and a static web page where people find out where they're going to move into. It's 3:00PM, you need to get out of there by 5:30PM and be back at the place at 8:00AM the next day to help everyone move in. What do you do?

Fear not, strong co-op, for thou art familiar with The Perl. You:

  1. ..load each record of your sturdy host database with only the fields IP address (which you can tell the VLAN by), room number (the old one) and hostname (for convenience) into an array of arrays using constants to gain an extra speed boost when searching
  2. ..fetch the static page with LWP::Simple and scrape the only the tables you want into an array using HTML::TableExtract
  3. ..create a new array of hashes to cross reference two data source to determine what machines were in the old office, sorted by new room number and omitting the labs you've already wired
  4. ..use the Template Toolkit to print out a nice report you can carry from room to room:

|  Room  |                       IPs                        |      Name       |
|--------+--------------------------------------------------+--------------- -|
|  238   | (             |  Joe Tenure     |
|        | (               |                 |
|--------+--------------------------------------------------+--------------- -|
...   |  ...                                             | ...             |

You write the script in an hour and finish outfitting the offices. Well done!

(Actually, I never saw "Seabiscuit," but you get the idea.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.