Re: searching complex datastructures

2003-12-11 Thread wren argetlahm

--- Charlie Garrison <[EMAIL PROTECTED]> wrote:
> I'm no expert (& I'd love to hear from one). But
> when I need to do something
> similar I use a second data structure for doing the
> 'reverse lookup'.

I thought about that, but was put off by the fact that
it's a complex structure-- of course I'm only
reverse-looking up one field, so it might work. I have
an estimated 1-10 lookups per database entry, of which
there are ~500 right now. So there might be time
savings, but memory requirements might be an issue


--- Fred Eiden <[EMAIL PROTECTED]> wrote:
> How about using a different data structure?  Maybe a
> hash of hashes would
> work better.  If the value of $xml_index is unique,

$xml_index is unique (as is the name value), but the
reason for the array is to sort the entries into an
order which doesn't necessarily correlate with
$xml_index or the name, and I look things up by their
order more often than their $xml_index.

~wren

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/


error catching and hashes

2004-01-09 Thread wren argetlahm
I've recently discovered the joys of return undef; for
error catching, but I'm having problems when the
subroutine returns a hash (unless there's an error).
Something like the following:

%hash = &subroutine($input) or &error($error);

returns the expected "odd number of elements in hash
assignment" warning. Is there a way around this aside
from returning a hash reference instead? is there any
particular reason to/not to return a reference
instead?

~wren

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


Re: error catching and hashes

2004-01-10 Thread wren argetlahm

--- Piers Cawley <[EMAIL PROTECTED]> wrote:
> This is because 'return undef;' is good, but
> 'return;' is better. It
> returns the correct, context dependent
> representation of false.

That seems to have fixed my problem, but I'm not sure
why it works. My &error($error) is now something to
the effect of {print shift; return;}, but why does
that return false?

~wren

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


Re: error catching and hashes

2004-01-10 Thread wren argetlahm

--- Bruce Van Allen <[EMAIL PROTECTED]> wrote:
> If no EXPR is given, returns an empty list in 
> list context, the undefined value in scalar 
> context, and (of course) nothing at all in a 
> void context.

Ah. For some reason I was under the impression that
without EXPR, return() returned the last value (as not
having a return does).

~wren

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


tricky parsing question

2004-01-22 Thread wren argetlahm
I'm working on a linguistic module and I'm trying to
find a good way to split a string up into "segments".
I can't assume single charecter strings and want to
assume maximal segments. As an example, the word
"church" would be rendered as the list ('ch', 'u',
'r', 'ch') and wouldn't break the "ch" up smaller even
though both "c" and "h" are valid segments in English.
I have all the valid segments for a given language
stored as keys in a hash, now I just need an algorithm
to chop up a string into a list. Any ideas?

~wren

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Re: tricky parsing question

2004-01-22 Thread wren argetlahm
--- Bill Stephenson <[EMAIL PROTECTED]> wrote:
> You need to get a book on regex's.

I know the solution lies in regex's, the problem is
that I can't quite figure out a generic enough way of
doing it. The problem is for a module and so the list
of valid segments is user defined. I guess I could do
something like:

$segs = '('. join('|', @segs) .')';
$string =~ s/^$segs//;
$first_seg = $1;

But I'd have to sort @segs somehow so that the longest
segments come first, and since alphabets can have many
many different segments, I worry about memory issues.

--- Bill Stephenson <[EMAIL PROTECTED]> wrote:
> Perl.com has the best available, "Mastering 
> Regular Expressions" is what you want.
> 
> Sounds like a formidable task though. For some
> additional help with your regex you can play 
> with a tool posted on the "perlhelp.com" web 
> site. Go to "Resources" and look for the 
> "Regular Expression Explanation Generator".

Thanks, I'll have to check those out sometime.

--- Rick Measham <[EMAIL PROTECTED]> wrote:
> Wren, when you say 'segments' it appears you 
> mean phonemes or phonetics.

Yeah, I do mean phonemes (or something like it). The
module is language independent, but I'll check those
modules out.

--- Chris Devers <[EMAIL PROTECTED]> wrote:
> Your definition of "segment" here is vague; is 
> it safe to ignore that and just accept that a 
> canonical list of each language's 'segments' is 
> a static thing that is already stored as hash 
> keys?

By "segment" I mean the smallest charecter or sequence
of charecters that has a regular pronunciation. But
yes, it's safe to ignore that and assume there's a
cannonical list of "segments" already in memory.

I am indeed associating the segments with values,
hence storing them as keys in a hash. Also, by storing
them that way, if I'm trying to find the values
associated with a given segment, I can quickly find it
by $all_segments{$segment_in_question} rather than
needing to do a for or foreach loop over an array of
an estimated 15..50 items.

The loop based off the longest element thing sounds
like a good idea, I'll see if I can get it to work.

For those who wonder what on earth I'm up to... it's
an OO module for autosegmental phonology. In short you
feed the object a string and an "alphabet" which maps
segments to values ("d" has +voicing, +dental,
-vocalic, etc) and it creates an array of hashes (or
hash of arrays) where the index is the sequence number
of the segment in the string, and where the key is the
name of the "tier" (voicing, dental, vocalic, etc).
Then there'll be ways to muck around with the object
ala phonetic rules. Then there'll be a method to tie
all of the tiers back together into a single string
(per the alphabet) and spit it back out.

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Problem with objects

2004-01-23 Thread wren argetlahm
I've come up with an idea for an object oriented
module and am making it in order to learn a bit more
about objects and OOP. I've run into a strange problem
that I can't figure out why what's happening is
happening. I'm trying to copy part of a data structure
from one position in the object to another. I have the
following two lines:

print %{$this->{'alphabet'}{$segments[$i]}};
$this->{'segment'}[$i] =
%{$this->{'alphabet'}{$segments[$i]}};

For some reason the %{$this->...} returns what it
should in the print statement (namely a list of a key
and a hash reference) but in the = statement it always
returns the string "1/8".

~wren

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Re: Problem with objects

2004-01-23 Thread wren argetlahm
--- Thilo Planz <[EMAIL PROTECTED]> wrote:
> It is a problem of context.

That's what I figured, but I wasn't sure off-hand how.
Thanks for the insight (you too Charlie). I had it set
up as $scalar=$ref initially but that introduced some
major problems that took a while to hunt down-- namely
that it just makes a reference (duh) to the data but
doesn't actually copy it over (the new copy needs to
be manipulated without affecting the old copy). Your
other option, $scalar={%{$ref}} , will work nicely.
Thanks again.

~wren

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Re: Problem with objects

2004-01-23 Thread wren argetlahm
--- Thilo Planz <[EMAIL PROTECTED]> wrote:
> What you probably want is
> 1)$this->{segment}[$i] =
> $this->{alphabet}{$segments[$i]}
> or
> 2)$this->{segment}[$i] =  {
> %{$this->{alphabet}{$segments[$i]}} }

On second thought... I tried the second option, and I
ended up getting the same behaviour as the first
option, namely a reference to the original data rather
than a copy of it. Thinking about it, I think I know
why. The hash referenced by $this->... is a hash of
hashes (or more precicely, of references to hashes).
So we're copying over the keys and the references, but
those refs point to the saame old data.

I've managed to solve the problem by borrowing a
subroutine from XML::Smart which walks along the data
structure and makes a copy of it piece by piece.

~wren

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Re: tricky parsing question

2004-01-23 Thread wren argetlahm
--- Chris Devers <[EMAIL PROTECTED]> wrote:
> Do you need to handle ambiguities? For example,
> "-ough" can famously be pronounced several ways:

The way it's set up now can't deal with them, but I'm
about to rewrite the thing to handle more than one
segment having the same orthographic representation.
Output can be ambiguous without any problems so long
as a given bundle of features has only one
representation. But the input needs to be
non-ambiguous on some level, so you'd want to either
assume all "-ough" are the same phoneme and that
pronunciation depends on context (a bad assumption in
this case), or you'd want to find some way to
differentiate them (e.g. by typing your string in as
IPA rather than English, or by "making up" segments
like "ough{ow}", "ough{off}", etc).  Generally, it
should be able be swept under the carpet of
predetermined lists.

> Okay, but I still think that attacking this 
> problem will be easier if you start out with 
> these elements in a normal, hand-ordered list, 
> and then pre-populate the keys of one or more 
> hashes based on that.

My current approach sorts segments by length (long to
short) then alphabetically. This allows users to list
the segments in any order they please. Maybe they want
to list "sch" with "ch" in their German alphabet, or
maybe they want to list "sch" with "s"; I think the
program should be agnostic as to the order in which
they're stored in the file. The only reason I can
think of for hand-ordering is if that order represents
information that can't be otherwise calculated (such
as ordering them by their frequency in the given
language in order to speed up parsing input). This is
what I'm currently using to get from $string to
@segments:

my (@length, @letters, @segments, $letters);
foreach (keys %{$this->{'alphabet'}}) {
push @{$length[length($_)-1]}, $_;
}
for (reverse [EMAIL PROTECTED]) {
push @letters, sort @{$length[$_]};
}
$letters = '(' . join('|', @letters) . ')';
while ($string) {
if ($string =~ s/^$letters//) {
push @segments, $1;
} else {
return &error("can't parse next segment in
'$string'");
}
} 

Using substr() might speed things up, but for now I'm
just hoping to get it all to work.

> I have a feeling that decomposing the string 
> into an array of characters might help

In short, that's what I'm doing, only replacing the
word "characters" with "segments" (which are generally
one character long, but not always). I'll look into
Parse::RecDescent, but so far I seem unable to grok
what I've read about it.

~wren

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


Developer Tools & iTunes

2004-02-10 Thread wren argetlahm
I'm a newbie to Perl on *nix and am in the process of
converting from MacPerl to OSX and I've just recently
downloaded the developer tools for OSX10.2 because I
was under the impression that they're necessary to
really use Perl on OSX (i.e. to use CPAN, Camel Bones,
etc). But installing the packages'll take nearly a gig
which is more space than I have on my startup
partition; so I'm wondering if they really are
necessary to use Perl?

Second question: If I need them I'll need to
repartition my disk which means that I'll loose all my
playlists on iTunes. I'm wondering if there's any way
to conserve them --the actual playlists, not just the
list of song ID#s that's in the "iTunes Music
Library.xml" file-- and if not, what would be a good
general idea for a perl approach. I get the impression
that Mac::Glue might be of use for the perl approach,
but I've never been able to get it to install properly
and I doubt the MacPerl version could talk with the
OSX program (could it?).

Thanks,
~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: Developer Tools & iTunes

2004-02-10 Thread wren argetlahm
Thanks everyone for the information, especially Chris
Devers for the suggestions on how to crop things out.
I just realized that the *.dmg file for the dev tools
is on my startup drive, so if I move that to another
drive it should free up enough space if I don't
install the documentation.

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Developer Tools Hijinks

2004-02-10 Thread wren argetlahm
Installing the dev tools has done horrible things to
my computer. The drive says it has 80MB or so left,
but most every program I run complains about the disk
being full and won't run; including trying to burn CDs
to back things up before repartitioning it all. Is
there any way to uninstall the dev tools? No log was
placed in the Installer Logs folder for me to do it
manually

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: can anyone help me with this install for OS X Server?

2004-02-12 Thread wren argetlahm

--- "Jason F.B." <[EMAIL PROTECTED]> wrote:
> Using OS X Server 10.2.8, Upgraded to 10.3 
> Server Since I upgraded to 10.3 I have not been 
> able to get Perl to work. 

Others on the list will be able to give you a much
better answer than I but, I believe the problem is
that you need to install the Developer Tools from
Apple. Ye be warned, these'll take up to a gig of
space and need to be on your boot disk/partition. 

Half of that's documentation, and much of the rest is
aimed towards GUI programming; look back a little bit
in the archives for tricks on paring the DevTools down
(thread: "Developers Tools & iTunes")

Perl, as installed, should still work fine (try
running a simple "Hello World" program, frex). But in
order to install most modules not in the standard
distribution you'll need the DevTools (which include
the commandline program "make").

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Installing 5.8.3

2004-02-15 Thread wren argetlahm
I just installed Perl 5.8.3 per the instructions on
.
They worked as advertised up until the end when I
type:

% perl -v

and it comes up with the default v5.6.0 built for
Darwin. Where did I go wrong?

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: Installing 5.8.3

2004-02-15 Thread wren argetlahm

--- Adrian Howard <[EMAIL PROTECTED]> wrote:
> Try
> /usr/local/bin/perl -v
> to check that it installed okay.

Yeah, I was hoping to keep the system's perl untouched
(having heard horror stories). That did it, thanks :)

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


*nix Perl newbie Question

2004-02-15 Thread wren argetlahm
So I finally made the switch from MacPerl to Perl
5.8.3 on OSX (10.2.8) and I can't seem to get things
working quite right. I'm having problems using
modules.

% perl -I ~/lib script.pl
#!perl
use module;

...(or moral equivalent) works fine but:

% ./script.pl
#!perl -I ~/lib
use module;

...and:

% ./script.pl
#!perl
use lib '~/lib';
use module;

...both return the error that they can't find the
module, even though @INC is modified as it should be.
What's up?

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: *nix Perl newbie Question

2004-02-15 Thread wren argetlahm

--- Sherm Pendley <[EMAIL PROTECTED]> wrote:
> Are you *sure* that's the error you're getting?

the actual shebang line is:

#! /usr/local/bin/perl -I ~/Library/Perl

The error is:

Can't locate WREN/Numbers.pm in @INC (@INC contains: 
~/Library/Perl [...snip...]) at ./t.plx line 3.
BEGIN failed--compilation aborted at ./t.plx line 3.

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: *nix Perl newbie Question

2004-02-15 Thread wren argetlahm

--- Doug McNutt <[EMAIL PROTECTED]> wrote:
> I worry that the ~/ convention for the home
> directory is a shell convention. In the first 
> case it is expanded by the shell while in the 
> other cases it's expanded by perl. Does perl 
> honor the option? When you say @INC is properly 
> modified is the expansion done in the list as 
> displayed?

It doesn't expand in the error message, spelling it
out fixed the problem though. Thanks for the help.

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


using CPAN to install Mac::Carbon

2004-02-15 Thread wren argetlahm
In my efforts to get Perl5.8.3 all set up I tried
installing Mac::Carbon via the CPAN shell. But it just
enters a loop of running the test files (unless I
don't do what the dialog boxes say, in which case the
make fails). What am I doing wrong?

~wren

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Re: using CPAN to install Mac::Carbon

2004-02-16 Thread wren argetlahm
--- Chris Nandor <[EMAIL PROTECTED]> wrote:
> Not giving me more information with which I 
> could diagnose the problem!  :-)
> 
> What is "enters a loop of running the test 
> files"? Do you have logs?

Sorry bout that :) I tried using CPAN to install it
again but now it tells me the module is up to date so
it seems to have installed somewhere along the line.

~/.cpan/histfile only seems to record commands I type
in not all text of a session. Basically the CPAN shell
would run the test (dialog with command to pick the
number between 2 and 4, dialog to remove brackets from
text, etc) and then after a while it would go through
those tests again, then again,... The only way out of
the loop is to not do what the dialogs say, in which
case the test fails and you eventually get back to the
shell command line with comments that the tests
failed.

~wren
P.S. What exactly are the darwin and auto folders for
in my site_perl?

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Getting info from iTunes

2004-02-29 Thread wren argetlahm
I was wondering if there was a good way to get
information about the currently playing song in
iTunes? Browsing through CPAN all I could find were
modules for controlling iTunes (play, pause, etc) with
a few assorted other commands (make new playlist, etc

~wren

__
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools


Re: Getting info from iTunes

2004-03-02 Thread wren argetlahm
--- Chris Nandor <[EMAIL PROTECTED]> wrote:
> I've got two scripts that do it.  happening is a
> script that updates your 
> iChat status, and np.pl is an X-Chat Aqua script

Thanks a bundle. I've figured out generally what
`happening` is doing, though the details of the
Mac::Glue stuff'll take a bit more reading.

One question I had was what format iTunes normally
stores the song name, artist, etc in. I don't use
iChat and when I pipe the output to the terminal
instead, strings with non-standard charecters (e.g.
cyrillic, japanese) are rendered as `?`.

~wren

__
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


Re: Icon in Address Bar

2004-04-26 Thread wren argetlahm

--- Charles Albrecht <[EMAIL PROTECTED]> wrote:
> You can also indicate this file using a header 
> along the lines of:
>  
> 

While on that thought and keeping it perl related, how
would one make that sort of a tag from CGI.pm under
the $CGI->start_html() function? Is there a way less
kludgy than...?

$CGI->start_html('-head' => [''])

~wren




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


[OT] Localization

2004-05-04 Thread wren argetlahm
I have an account on my box that has Japanese set as
the default language and I noticed that certain files
get automagically renamed into Japanese (e.g. various
Apple programs in /Applications). I also noticed that
this is blocked if I change the name of the app (e.g.
from "iTunes" to "iTunes 4.5"). In short, I was
wondering where this sort of localization information
is stored so I can muck around with this
dual-filenaming feature.

~wren




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


Re: [OT] Localization

2004-05-06 Thread wren argetlahm

--- Thane Norton <[EMAIL PROTECTED]> wrote:
> The complete "official" answer can be found 
> here:

Wow that's a long URL. Thanks a bundle* for it though,
it has what I was looking for (which was localizing
some of my folder names rather than localizing apps).

~wren
* pardoning the pun ;)




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


Re: Basic question

2004-05-22 Thread wren argetlahm
--- Rich Morin <[EMAIL PROTECTED]> wrote:
> Given that the Perl executable may be located in 
> any of several places, hard-coding a path into 
> the shebang line isn't all that great an idea.  
> The following will always give you the version
> of perl that comes first on your search path:
> 
>#!/usr/bin/env perl

That's a cool suggestion, but I had a couple
questions. Is it good to hardcode the path to `env`,
or just not as bad as hardcoding the path to `perl`?
And how is this different/better than just using
"#!perl"?

Second, and somewhat more personal, I have an
alternate perl (5.8.1) at /usr/local/bin so as not to
clobber the default system perl (5.6.0). I also have
my path set up so the system default is the first in
the path (meaning I need to either type
`/usr/local/bin/perl` or `perl5.8` to get my perl). Is
this path set up necessary to avoid munging with
things that use the system's perl, or are things that
use the system's perl set up to bypass the path?




__
Do you Yahoo!?
Yahoo! Domains – Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 


CPAN troubles

2004-06-16 Thread wren argetlahm
It seems to be working fine eventually but I'v noticed
that I've started getting this error when I run CPAN:

LWP failed with code[500]
message[LWP::Protocol::MyFTP: connect: Invalid
argument]

I was wondering what might be causing that?

~wren



__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail


Re: Mac::Glue::VERSION

2004-07-21 Thread wren argetlahm
--- Chris Nandor <[EMAIL PROTECTED]> wrote:
> At 19:15 +0100 2004.07.21, John Delacour wrote:
> >I presumed that by running
> >cpan> install Mac::Glue
> >all prerequisites would be installed by cpan in
> order to enable me to
> >install and use it.
> 
> Yes, unless you specifically tell the CPAN shell to
> not do so.

This is just an FYI, but I seem to recall back when I
was first trying to install Mac::Glue there was some
problem with cpan.pm not following the prerequisites
and installing them as it usually does.

Each time I tried installing it, it failed saying I
need X module, so I installed X and retried until
eventually it went through fine. It did always tell me
what I needed. I'm not sure why cpan might fail to
follow the prereqs (I've never had the problem with
any other module and I haven't ever changed my
configuration), but there could be some weird conflict
going on.

More recently when upgrading those prereqs I got a
similar thing, but this time it was a newer version of
a prereq than I had that was needed; I don't know if
cpan will usually follow specific-version
dependencies.

~wren




__
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/


[OT?] Shebang question

2004-07-21 Thread wren argetlahm
Sorry if this is off-topic, but I seem to recall
sometime fairly recently (less than a year, more than
a few weeks) someone mentioned a way to "autofind" the
path to perl on the shebang line so you don't need to
hardcode the path. I can't seem to find the post in
the archives. Does any one remember the method or what
thread it might have been mentioned in?

~wren



__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail


Forking & Signals

2004-08-19 Thread wren argetlahm
I have a perl script (modified from one of Chris
Nandor's) that I run as a background-process/daemon
via fork(). Now I know I can use kill to end it, but I
was wondering if there was a way that I can catch the
SIGTERM to do one last thing before quitting? It looks
like it should already do this, the relevant code goes
like:

$SIG{CHLD} = 'IGNORE';
my $pid;
if (1) {
$pid = fork;
if ($pid) {
print "Running background process ($pid)\n";
exit;
}
}
END {
&output() unless $pid;
}

... which I interperate as when the parent quits
(exit) nothing happens, but when the child quits
(kill) it should run &output(). This doesn't happen
though. Is there another way?

~wren
(Perl 5.8.3, OSX 10.2.8)



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


Re: Forking & Signals

2004-08-19 Thread wren argetlahm
--- Neil Bowers <[EMAIL PROTECTED]> wrote:
> You just need to install a TERM handler routine in
> the child process. 

--- Jerry LeVan <[EMAIL PROTECTED]> wrote:
> See http://homepage.mac.com/levanj/LinkSys and grab
> linksys.pl.

Ah thanks. In my foolishness I didn't think to RTFM
(perlipc). Having read it now (and tested the
suggested code), I still have a question.

So we have a really basic program: a "fork loop",
&cleanup, and an END block. If I set $SIG{'TERM'} to
\&cleanup in the loop we get the END block when the
parent exits, and then when we kill the child we get
&cleanup and then END again. So far so good.

Now if we take that same simple program and either
don't define $SIG{'TERM'} or set it to 'DEFAULT' we
get END when the parent dies, but when we kill the
child &cleanup isn't run (duh) but neither is END. Is
that standard behaviour? I would've thought it'd try
to do END if at all possible to clean up after itself.

~wren

#!/usr/local/bin/perl
if (1) {
$pid = fork;
if ($pid) {
print "Running background process ($pid)\n";
exit;
} else {
$SIG{'TERM'} = \&cleanup;
while (1) {}
}
}
sub cleanup { print "foo\n"; exit 0; }
END { print "bar\n"; }
__END__



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


Re: [OT] Brand New Empty Mac

2004-08-25 Thread wren argetlahm
--- John Horner <[EMAIL PROTECTED]> wrote:
> But I just thought I'd get the opinions of the list
> on the best way to set up such a brand-new machine
-- do you
> partition your hard-drives? Do you have the system
on one 
> partition and documents on another and so on? Any
issues 
> around the installation of Perl and other things
like C libraries 
> that I should be thinking about?

Generally speaking I haven't had need to install any
libraries (or other *nix goodies) other than those
from the developer tools. I needed libraries for
OpenOffice and TeXShop, and occasionally for specific
Perl modules (expat, libxml2). Other *nix stuff I've
done include lynx/links/elinks (for webdesign testing)
and CVS. I'd say, do the stuff for OOo and TeXShop if
you're into that, otherwise just install them as you
need them.

I'm all for partitioning. I haven't had the issues
that a bunch of others apparently have (I am still on
Jaguar though). My current partitions are something
like System (4GB), Volatile (8GB), and Static (25GB).
System holds most boot and / stuff along with
developer tools; Volatile holds most of my documents,
/Users, and /Applications* (and perl's site_lib
incidentally); and Static holds my media that change
rather infrequently (MP3s, movies, developer tools
documentation, some images).

The upsides to this arrangement are: if I toast my
system I can just wipe the partition and reinstall the
OS without needing to reinstall all my applications
(*nix programs will need reinstall, but they're
smaller, by and large; and OOo will need reinstalling)
and without damaging preferences, user files, etc. On
a production rather than development box this would be
less important. Also if I want to search for something
I can pretty reliably limit where I'm looking to about
8GB out of 40. And it helps keep things looking clean
since I have a bunch of files that are shared and
/Users/shared has other purposes according to various
installers. (Though I suppose you could just dump them
all in a folder on your single partition.)

The downsides are that you need to watch your free
space when considering partition size: make sure you
have enough swap space on System (so on Panther that'd
be 3~10GB after all the OS, C libraries, *nix
programs, Xtools), and make sure you have enough free
space on Volatile for any large downloads and for the
iTunes preferences/library (iTunes gets quite
persnickety if you run out of space, and can start
harming the system too). And you need to bear in mind
the limitations of moving /Applications off the boot
partition.

* Moving /Applications is considered by most to be a
_bad_ idea. Since I have about 5GB of Aqua/OSX
applications the ability to avoid reinstalling them is
worth it to me. There are a few different methods of
doing so, I chose the one resembling moving /Users--
namely just put it where you want and make a symlink
(for /Users you'd also have to go in and mess with
NetInfo)-- because it seemed to have the fewest/least
severe issues involved with it.

The biggest problem I've noticed with this method is
that Software Update doesn't always respect the
symlink and will occasionally overwrite it with a
folder of the same name and drop whatever in there
(not always a whole .app bundle either; e.g. Safari
1.0.1 to 1.0.2), or sometimes just won't work at all
(e.g. the iTunes 4.4 to 4.5 update appears to have
gone to /dev/null every time until I made the
/Applications folder and moved iTunes into it). This
has been annoying but since I knew about it getting
into things it hasn't surprised or bothered me too
much; again, it doesn't happen reliably, just often
enough to bear in mind. The only other downside I've
noticed is that Disk First Aid can't properly scan the
disk it's running on.

If you were to follow this method, I'd suggest
installing that first huge batch of Software Update
stuff before moving /Applications over, just to avoid
any possible problems since there're so many updates
on a brand new system.

FWIW, YMMV, etc,
~wren



___
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush


Thunderbird

2004-09-21 Thread wren argetlahm
I've recently started messing around with Thunderbird.
I like it a bunch but I'm wondering if there's any
good way to port over my Address Book, with perl or
otherwise.

I've tried exporting from AB (as .vcf, the only
option) then importing in Thunderbird (.vcf isn't one
of the formats listed that it can import, but it
doesn't tell me I can't do it). A new address book
list icon thing shows up, but so far as I can tell the
information isn't actually imported. My second attempt
was going to be through Mac::Glue, but Thunderbird
doesn't appear to support AE (which makes sense).

Any other suggestions? 

~wren



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


Re: Thunderbird

2004-09-22 Thread wren argetlahm
--- Ken Williams <[EMAIL PROTECTED]> wrote:
> You might be interested in this page, entitled
> "Import Address Book 
> records into to Thunderbird" :
> 
>
http://www.macosxhints.com/article.php?story=20040905025741769
> 
> When I googled for "thunderbird" and "address",
> trying to learn what 
> thunderbird was, this was the first link that came
> up.

Yeah, shortly after posting I did the google and found
that page. Tried the script, it had some issues* but I
tinkered with it until I got it to work. But even
then, Firebird's import didn't seem to find anything
in the file. (After you load the file there's a pop-up
to link specific fields in the file to specific fields
in the Thunderbird format. But neither .vcf not .csv
seems to show up wih anything.) Since .csv *is* listed
as a text-type it understands, I wonder if this might
be a bug in the import abilities. I was hoping someone
else here uses Firebird and may have dealt with the
issue before.

* SImpleText doesn't like the "create new document"
stuff, so changed it to call TextEdit. And it craps
out on some of the addresses for no reason i can
discern, so I just commented that all out to produce
null addresses.

~wren



__
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail


Re: Thunderbird

2004-09-23 Thread wren argetlahm
--- Chris Devers wrote:
> --- Joel Rees wrote:
> 
> > I don't know about .vcf, but .csv is fairly easy
> to just look at with 
> > a text editor (formatting off, of course).

Yeah, they're both just text and (pretty) easily
readable. The problem comes in that I don't want to
stop using AddressBook and so I'm looking for a
"maintainable" solution, where I can just hit a couple
buttons or run a script rather than needing to
manually enter anything.

That's part of the reason i've been looking at FB's
import function and Mac::Glue. I don't know for sure,
but I'm thinking that FB doesn't offer any sort of
scripting API (ala Mac::Glue or commandline commands)
that'd let me enter the data programmatically if the
Import function doesn't work. I'd love to be disproven
however.

Incidentally, the .vcf file generated by AB looks akin
to your example but with a space between every
charecter and two newlines instead of one. Is that
normal, or might that be part of the reason that
Firebird is having difficulty reading it?

~wren



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


[OT] Text Editor for OSX

2004-10-03 Thread wren argetlahm
I apologize in advance for the off-topic nature of
this posting. I've recently been lamenting the
shortcomings of my current text editor for my purposes
(SubEthaEdit since my copy of BBEdit is Classic and a
new one costs way to much for my budget). I did a
quick google search to try and find out what other
options are out there, particularly in the F/OSS realm
and with good support for XML/HTML/etc. And I couldn't
find anything in particular. So, in my infinite (lack
of) wisdom I've decided that it might be good to write
my own.

Enter the problems. Since this is a large undertaking
and it is something I'd like to see finished rather
than remaining in my basement of weekend projects, I'm
looking for guidance. I figure I'll prolly turn
towards SourceForge as a place to host the project and
open it up to the unpaid armies of programmers. But
I'm wondering where all would be a good place to
explicitly seek out such armies? For those who've
played on the project management side of SF, is there
anything I should know (other than what's in the
documentation on their site, soon to be re-read)? Is
there someplace other than SF which might meet my
needs in this regard?

I'm also wondering what text editors y'all use (aside
from the obvious BBEdit) and, more importantly, what
features about them do you like so much? I have a list
of what I consider critical to the project, but I'm
wondering what I've left out to making this a viable
editor for the masses. One biggie for me is
sophisticated syntax highlighting. The highlighting is
definitely going to be extensible, but I'm wondering
what languages y'all would consider essential coming
out-of-the-box for the first release? So far I have:
XML-family (xslt, xhtml, rss), CSS, PHP, Perl, Ruby,
Python, JavaScript, Java, LaTeX, C-family (C, C++, C#,
Objective C), bash, and tcsh.

Since I'm pretty new to GUI programming on Mac, is
there a good place to look for critical analysis of
the best approach? (e.g. Cocoa or no, NSTextView or
no, strengths and limitations of different
approaches/languages, things to look out for, etc.)
I'll be developing on OSX 10.2.8, what sort of
limitations/compatibility issues should I be aware of
between 10.2 and 10.3?

My current vague thoughts are that I'll want to write
my own text pane object instead of using NSTextView
and that this will be the lions share of the
(conceptual) work. The other part being the program
that calls the object (which may take the lions share
of the time). I'm wondering how feasible it might be
to use a perl-ish approach for parts of the object
(w/r/t syntax highlighting, search-and-replace, etc)
or if that would make it too slow/introduce too many
dependencies.

I have work later today and all my time until then
will prolly be taken up with research for this
project, but I'm thinking I'll do a writeup for the
project sometime monday or tuesday and try to get
things in motion within the next week or two. More
information about the project's progress is liable to
be found at my website:
http://collab.freegeek.org/~wren/ . I appreciate any
and all feedback on this (especially any interest in
helping code/debug/mentor), though I'm thinking that
(unless TPTB feel it'd be a helpful discussion to have
on list) all correspondence should be directed to
[EMAIL PROTECTED] off-list.

Live Well,
~wren



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


Re: [OT] Text Editor for OSX

2004-10-04 Thread wren argetlahm
(Replying to all the messages in one)

I guess right now I'm mainly looking for a good (to a
certain extent, read: dedicated) XML editor and
haven't yet encountered one for OSX. Aside form the
"standard" text editor features, the two biggest
things I'm looking for are automatic (via keystroke)
closing element tags* and highly extensible syntax
highlighting.

I've been told that jEdit performs excellently at the
latter, but haven't had a chance to test it out yet.
One of the big things I'm looking for is the ability
to use multiple highlighting pragmas in the same file
(i.e. CSS embedded in HTML, JS in HTML, PHP in HTML,
XSLT in XML, HTML in XML (aka XHTML), et cetera).

* And other carpal-tunnel-avoiding/time-saving
mechanisms like block indent/outdent/commenting and
"tab completion" ala emacs' dabbrev-expand

--- "Chris Devers" wrote:
> Yes, that's what the world needs: Yet Another Text
Editor. 

But of course :-)

> I can think of two reasons why it would make any
sense to take on the 
> task of writing Yet Another Text Editor:
> 
>   1. You want to learn Cocoa programming. That alone
is a good reason.
> 
>   2. You have some brilliant new feature in mind
that can't really be 
> incorporated into existing software as a plugin 

I hadn't thought of it as a Cocoa-learning exercise,
though it would definitely be that. jEdit may break
the mold, but historically speaking all the text
editors I've used suffer from the limitation that they
can only really handle one set of syntax for the whole
file, and tend to fall apart with these "mixed"
content files; sometimes they'll be able to handle it
to some extent, but by and large it comes across as
kludgeish (e.g. defining CSS/JS/PHP as part of the
HTML syntax). While not the end of the world, "it
would be nice..." And, I mean I could use vim, it has
pretty good highlighting abilities, but it'd be nice
to get something good and Mac-ish. If after trying
jEdit I do decide to go ahead with the project I think
this may be The Big Feature to make it a worthwhile
editor: a way of having the file actually be
interpreted in different languages as appropriate. Not
just for highlighting but also for validation,
spellchecking (e.g. only check the text nodes on a
webpage rather than calling the tags misspellings),
tag/quote/curly-brace/parens/... closing, doing block
commenting with the right comment-symbols.

I don't know if that'd count as "brilliant". It would
save a lot of time/energy to build on top of another
editor, and that would reduce the overall number of
editors out there, but I'd find it difficult to do the
sorts of things I'm thinking as a module since it
alters the underlying way text is handled.

--- "Doug McNutt" wrote:
> I'm not so sure about the OT designation. 

Since Perl is what I know, and Perl is really good
with text I've been debating possible Perl-oriented
approaches. But I'm wondering why you're not so sure
about the OT designation?

> It is likely that you could find support for your
effort on the MPW 
> mailing list <
http://lists.apple.com/mailman/listinfo/mpw-dev > 
> especially if you are interested in making the
editor a real shell 
> while you're at it. 

Depending on what all this "real shell" entails, I may
very well be interested. Ideally the end product would
have good integration with commandline programs (such
as `wc` and others I can't think of off the top of my
head, ability to run scripts/programs and direct
output to a window, etc). I've never messed with MPW,
mind, so who knows if what I'm hoping for would bear
much resemblance to it.

--- "Joel Rees" wrote:
> I'm a little lazy right now. Was SubEthaEdit
originally on open source
> project?
> 
> (And did Wren notice BareBone's TextWrangler and
decide that didn't go 
> far enough?) 

I don't know if SEE was ever open source. For some
reason I'm thinking not, though I don't know where
that's coming from. If it is/was F/OSS I would be
interested in borrowing the network editing stuff (if
feasible) since that is what everybody cites it for. I
find the idea nifty even though I've never used it
myself and don't know if I ever will; but the overall
lack of preferences/customizability of SEE is one of
the big things turning me off of it right now.

I looked at TextWrangler a looong time back. I don't
remember much of anything about it. Of course one of
the things keeping me away from BBEdit is the cost, is
BBTW substantially cheaper or better yet F/OSS?

> One thought -- Wren, if you're going to go so far as
to write YATE, 
> I'd suggest your internal character encoding be a
thirty-two bit 
> encoding that uses the full thirty-two bits to allow
you to keep track 
> of input encoding on a character-by-character basis.
While Unicode 
> support is a must, I would not use it as an internal
encoding because 
> of the round-trip problems. 

The idea intrigues me, but I think I may be a bit too
naive about character encoding to get precisely what
you mean. What aspect of "input encoding" are you

Re: [OT] Text Editor for OSX

2004-10-04 Thread wren argetlahm
--- John Delacour <[EMAIL PROTECTED]> wrote:
> At 7:46 am -0700 3/10/04, wren argetlahm wrote:
> 
> >  So, in my infinite (lack of) wisdom I've decided
> > that it might be good to write my own.
> 
> Have you considered Alpha? 
> <http://alphatcl.sourceforge.net/>

I have not, this is the first I've heard of it.
Admittedly I find the wiki a bit difficult to
navigate; what are the strengths of it (or a URl to
such a description)?

~wren



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


Re: [OT] Text Editor for OSX

2004-10-04 Thread wren argetlahm
--- "Randal L. Schwartz" <[EMAIL PROTECTED]>
wrote:
> Hell, Emacs is Free.  How long do you have to work
> to write an editor
> better than emacs, making no money doing it? :-)

:-)  It's been a long time since I've tried out emacs,
the discovery of dabbrev-completion makes it sound...
tempting, but I remember back when first introduced to
*nix and was functionally told I must learn either
vi(m) or emacs, that emacs baffled me and I could
never get it to do anything I wanted, whereas
vim--though bizzare--I could at least get to do what I
wanted it to after reading the
documentation--documentation I had available for emacs
at the time was either non-existant or
non-educational.

~wren



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


Re: Options for control of output in Terminal?

2004-11-22 Thread wren argetlahm
--- Bruce Van Allen <[EMAIL PROTECTED]> wrote:
> For your use, what you especially want to get from
> this example is the use of the Perl character "\b",
> which outside of regular expressions means "
> backspace". The point is to print "\b" the same 
> number of times as the number of characters you
> want to back up before printing the updated output.

Just an FYI if using this process (print
"\b"x$length), it's frequently good to put a sleep(1)
in there. Otherwise I've found that some glitchiness
can occour (with things not being completely deleted
before printing starts and vice-versa). I haven't
tested the specific code given which may be better
than a similar thing I have used, and sleep() may not
suit your purposes, but just figured I'd give a heads
up.

live well,
~wren



__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 



Taint mode (was Re: Variables in external file)

2005-02-18 Thread wren argetlahm
--- Bruce Van Allen <[EMAIL PROTECTED]> wrote:
> And you will avoid the stress of combing back
> through a program you need
> to make secure, trying to find the elusive points
> where the -T switch
> tenaciously challenges you, an enterprise in which
> you may risk losing
> your appreciation of logically organized electron
> flows.

Which reminds me... I've been using the #!/usr/bin/env
perl shebang for easier distribution, but env doesn't
like switches. Is there a way to set taint mode via
`use` or the like (ala use warnings; for -w). I can't
seem to locate anything in the manuals other than the
-T flag.

Live well,
~wren



__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 


[OT?] libxml2/libxslt and OSX

2005-03-17 Thread wren argetlahm
This is only somewhat off topic, but I was wondering
if there were any packages out there for Mac OS X with
the necessary development C headers for libxml2 and
libxslt? I can only seem to find rpms of the same. If
not (brace yourselves) how difficult would they be to
create*?

Live well,
~wren

* given that the library compiles cleanly, we have the
source code, and the rpms for other architectures.



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


Re: [OT?] libxml2/libxslt and OSX

2005-03-17 Thread wren argetlahm
--- Chris Devers <[EMAIL PROTECTED]> wrote:
> The system should already have the libxml2
> libraries,

I'm still running 10.2 which doesn't include those
libraries (though I have them installed). Upon
reflection, it looks like I have the includes, just
not where I was looking for them.


~wren



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


Re: CamelBones on Intel? Maybe not.

2005-06-09 Thread wren argetlahm
--- Edward Moy <[EMAIL PROTECTED]> wrote:
> So what is really needed at this  
> point is for the CamelBones community to get
> together and innovate.   
> Create some killer apps with CamelBones.  Get
> developer excited about  
> this technology.

I'll bite.

Dunno if it'd count as "killer" or not but I have a
F/OSS project I've been working on that's been looking
for a GUI for a while. We were going to go with Python
for cross-platformability, but I've been thinking
about learning Cocoa for a while and have really
wanted to use CB for *something*.

Hey Sherm, I haven't toyed with CB since the days of
10.2, anything I should know before diving in again?

Live well,
~wren

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


[OT?] Dynamically loading Perl into C programs

2005-06-28 Thread wren argetlahm
There's a project I'm working on (Paperboy RSS) that's
written in C, the simplest part of which is basically
applying XSLT to files with libxml2/libxslt. There's a
separate but related project written in Perl that's
going to use paperboy to do the heavy lifting but
needs to be able to let users define their own
XSLT/XPath functions. Since these functions are
user-defined I need to find some way to dynamically
load them into paperboy at runtime.

So my question is, what's the best/easiest way to do
this? Ideally paperboy would be dynamically loading
another C object file so that we could have a number
of these for writing xpath functions in different
languages; though that's not strictly a requirement.
I've had Apache2's libperl suggested to me, but my
weak google-fu can seem to find anything relevant on
that. Any guidance is appreciated.

Live well,
~wren

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com