Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Dec 1998 11:22:29 +0000
From:      nclayton@lehman.com
To:        Steve Price <sprice@hiwaay.net>, Gary Howland <gary@hotlava.com>
Cc:        doc@FreeBSD.ORG, wosch@FreeBSD.ORG, asami@FreeBSD.ORG
Subject:   Re: ports INDEX perl Module
Message-ID:  <19981208112229.T543@lehman.com>
In-Reply-To: <Pine.OSF.4.02.9812071224340.8033-100000@fly.HiWAAY.net>; from Steve Price on Mon, Dec 07, 1998 at 12:32:49PM -0600
References:  <19981207154741.28355.qmail@abc.aaa-mainstreet.nl> <Pine.OSF.4.02.9812071224340.8033-100000@fly.HiWAAY.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Dec 07, 1998 at 12:32:49PM -0600, Steve Price wrote:
> I have some related stuff that might help if you're interested.
> You can also find the list of wants/needs that Wolfram Schneider
> put out here:
> 
> http://www.freebsd.org/cgi/getmsg.cgi?fetch=76128+79859+/usr/local/www/db/text/1998/freebsd-ports/19981018.freebsd-ports
> 
> -steve
> 
> On 7 Dec 1998, Gary Howland wrote:
> 
> # If no one has volunteered yet, then I'll volunteer for this project.
> # Let me know if someone is working on it or not, and if available,
> # give me as much details as poss, and I'll start ASAP.

I started working on this, and wrote some code which I mailed to Wolfram
and Satoshi -- I appear to have lost it, so I've cc'd them on this message
in the hope that's they hung on to it.

Basically, it implemented two objects. FreeBSD::Port was an individual
port. You created it calling the new() method, passing it one line from
the ports INDEX file. The object read this in and set its internal state.
It then provided methods to get this info back. There were also two methods
that returned a multi-line string of information, one as text, the other
as HTML.

The second object was tied hash. You passed it the filename to the INDEX
file and it went and created all the ::Port objects as necessary. The hash
key was the name of the port.

So you'd write code like

    use FreeBSD::PortsIndex;

    my(%i, $i);
    tie %i, FreeBSD::PortsIndex, "/usr/ports/INDEX";
    $i = tied(%i);

    # Get information about a port
    print $i{"foo-1.1"}->maintainer(), "\n";

    # Set information about a port
    $i{"foo-1.1"}->maintainer("foo@bar.org");

    # Dump all information about a port
    print $i{"foo-1.1"}->as_text();

    # Turn the port's information back into an INDEX line
    print $i{"foo-1.1"}->as_index();

    # Create a new INDEX file that contains the changed information
    open(F, "/tmp/INDEX") or die "Can't open /tmp/INDEX";
    print F $i->as_index();
    close(F);

Because FreeBSD::PortsIndex was a tied hash, you could use the normal Perl
operators (sort(), keys(), each(), etc) to iterate over it.

That's as far as I got. I didn't re-write any existing programs to use
these new objects.

N
-- 
--+==[ Systems Administrator, Year 2000 Test Lab, Lehman Brothers, Inc. ]==+--
--+==[      1 Broadgate, London, EC2M 7HA     0171-601-0011 x5514       ]==+--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981208112229.T543>