SPUG:Microsoft: Open source threatens our business model

Fred Morris m3047 at inwa.net
Tue Feb 18 01:48:09 CST 2003


I remember you. You had something to say about my "my two perl gizmos (CPAN
module paralysis)". The only problem is that your comment missed the mark;
quite simply you didn't understand, as you so elegantly demonstrated by the
end of our exchange at that time.

Now, that was a private exchange; but you didn't see fit to post any sort
of public correction. What I have of the exchange is therefore reprinted at
the bottom of this message. So I ask you: did Asa Mercer have a newspaper
in Wyoming or not?

Of course being wrong didn't stop you before...

Jonathan Gardner wrote:
>On Monday 17 February 2003 20:36, Fred Morris wrote:
>>
>> So the homesteaders are caught in the middle. And that is why Wyoming was
>> the first state to give women the vote. QED. See, Barons + Rustlers adds up
>> to 100%; women and homesteaders don't count.
>>
>
>I hate to be blunt with you, but this isn't making any sense. My family has
>their roots in Wyoming. Giving the women the right to vote had nothing to do
>with cattle barons or homesteaders or anything like that.
>
>The real reason they gave women the right to vote was because the Church (yes,
>the Mormon Church, or properly, the Church of Jesus Christ of Latter-Day
>Saints) taught that men and women were equal, and they both should have the
>right to vote. It just so happened that almost all of the settlers in Wyoming
>(and Utah and Nevada and Idaho and parts of Mexico and Canada) were members
>of that church.
>
>As far as cattle barons causing people to slaughter their cattle at a younger
>and younger age -- hogwash. Barons had no control over the settlers then. I
>should know. My great-grandmother who passed away a few years ago at the ripe
>age of 103, and all of her relatives had no problems with barons or such.
>They had plenty to eat and wear, and their houses were more confortable than
>you think.
>
>--
>Jonathan Gardner
>jgardn at alumni.washington.edu
>Python Qt perl apache and linux

--

Fred Morris
m3047 at inwa.net

--

Delivered-To: m3047 at inwa.net
X-Authentication-Warning: mail.pm.org: majordomo set sender to
owner-spug-list at pm.org using -f
X-Sender: m3047 at mail.inwa.net.
Mime-Version: 1.0
Date: Thu, 19 Dec 2002 06:17:19 -0800
To: spug-list at pm.org
From: m3047 at inwa.net (Fred Morris)
Subject: SPUG: My two perl gizmos (CPAN module paralysis)
Sender: owner-spug-list at pm.org
Precedence: bulk

Very briefly, here are short synopses of the two modules which I have
contemplated submitting to CPAN. I know that left to my own devices, that
will never happen.

Both of these modules are utilized in a working application which gets
daily use.

Maybe this'll encourage others to share theirs, and we can get together and
at least get the peer review issue out of the way (there are a number of
impediments standing between me and CPAN, peer review is only one). Or,
maybe somebody will be interested enough to say "hey, I could use that!".
Be aware, neither of them is packaged for distribution at the moment
although anyone who's competent with Perl should have no problem getting
them to work; they do have POD.


A CANONICALIZED STRING CONSTANT RESOLVER

Problem:

Generally speaking, localization. This means for languages, but also for
different parts of an application, or different applications of reusable
parts.

Utility:

I find it useful, but mostly I just think it's cool. The overhead for this
might be somewhat large in a occasionally-used Perl script, but with
mod_perl a persistent hash is constructed of particular fully-qualified
names which have already been resolved.

Synopsis:

The constants are all retrieved with a function call which takes as a
parameter a key which will resolve to a constant (or filter, I lied).

So, you define something like

  Success => { 'string', 'Done!' }

You reference it in different places as

  $cliches->cliche( 'SomeModule.Frotzify.Success' )
  $cliches->cliche( 'ThisModule.Frappe.Success' )

You may decide that when you Frappe you want a different message or when
you Stir in SomeModule the same thing is needed, and so you define
overloads (overrides?):

  Frappe.Success => { 'string', 'Cheers!' }
  SomeModule.Stir.Success => { 'string', 'Mixed!' }



EMBEDDED SQL IN AN HTML REPORT TEMPLATE

<snip>

Fred Morris
m3047 at inwa.net



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

Delivered-To: m3047 at inwa.net
From: Jonathan Gardner <jgardn at alumni.washington.edu>
To: m3047 at inwa.net (Fred Morris),
 spug-list at pm.org
Subject: Re: SPUG: My two perl gizmos (CPAN module paralysis)
Date: Thu, 19 Dec 2002 09:08:20 -0800
User-Agent: KMail/1.4.3
MIME-Version: 1.0

On Thursday 19 December 2002 06:17 am, Fred Morris wrote:
> Very briefly, here are short synopses of the two modules which I have
> contemplated submitting to CPAN. I know that left to my own devices, that
> will never happen.
>
> Both of these modules are utilized in a working application which gets
> daily use.
>
> Maybe this'll encourage others to share theirs, and we can get together and
> at least get the peer review issue out of the way (there are a number of
> impediments standing between me and CPAN, peer review is only one). Or,
> maybe somebody will be interested enough to say "hey, I could use that!".
> Be aware, neither of them is packaged for distribution at the moment
> although anyone who's competent with Perl should have no problem getting
> them to work; they do have POD.
>
>
> A CANONICALIZED STRING CONSTANT RESOLVER
>
> Problem:
>
> Generally speaking, localization. This means for languages, but also for
> different parts of an application, or different applications of reusable
> parts.
>
> Utility:
>
> I find it useful, but mostly I just think it's cool. The overhead for this
> might be somewhat large in a occasionally-used Perl script, but with
> mod_perl a persistent hash is constructed of particular fully-qualified
> names which have already been resolved.
>
> Synopsis:
>
> The constants are all retrieved with a function call which takes as a
> parameter a key which will resolve to a constant (or filter, I lied).
>
> So, you define something like
>
>   Success => { 'string', 'Done!' }
>
> You reference it in different places as
>
>   $cliches->cliche( 'SomeModule.Frotzify.Success' )
>   $cliches->cliche( 'ThisModule.Frappe.Success' )
>
> You may decide that when you Frappe you want a different message or when
> you Stir in SomeModule the same thing is needed, and so you define
> overloads (overrides?):
>
>   Frappe.Success => { 'string', 'Cheers!' }
>   SomeModule.Stir.Success => { 'string', 'Mixed!' }
>

The only thing weird about what I see is that you might as well define
"$Success" and let namespaces do the rest for you. For instance, you can do:

$main::Success = "Done!";
$Frappe::Success = "Cheers!";
$SomeModule::Stir::Success = "Mixed!";

And just use "$Success" in the appropriate place.

As far as a way to do translations efficiently and well...  Qt is a C++ widget
library for Windows and X. It is probably the best platform to program for
localization and translation.

Qt uses a function called tr() (which unfortunately is a builtin in perl). You
pass in the string, and then define localization later. If we changed the
name to trn():

$cliches->cliche(trn("Done!"));

Later on, you can ask the module that defined trn() what string were used in
your program. With a list of all of your strings, you can translate it to a
different language or localization, put that into a file, and tell the module
to use that localization.

The problem is that you want to use a finite number of strings. For instance:

trn("Hello, $first_name")

is never going to get translated except for a finite number of $first_name.

The way to work around that is to do something like:

sprintf(trn("Hello, \%s!"), $first_name)

or something more ingenious, which probably exists in perl already.

Anyway, it's a couple of pennies, if that.

Jonathan Gardner
jgardn at alumni.washington.edu

Delivered-To: m3047 at inwa.net
From: Jonathan Gardner <jgardn at alumni.washington.edu>
To: m3047 at inwa.net (Fred Morris)
Subject: Re: SPUG: My two perl gizmos (CPAN module paralysis)
Date: Sat, 21 Dec 2002 11:03:55 -0800
User-Agent: KMail/1.4.3
MIME-Version: 1.0

On Friday 20 December 2002 09:02 pm, Fred Morris wrote:
> The point of the exercise is to have a $success which is not dependent on
> the namespace, or doesn't have to be declared into particular namespaces.
>
> >$main::Success = "Done!";
> >$Frappe::Success = "Cheers!";
> >$SomeModule::Stir::Success = "Mixed!";
>
> So, my namespace is Muddle, and I ask for the value of $Success. What
> happens?
>

It will say you don't have $Success defined. Depending on whether or not you
are use'ing strict, it will raise and error.

You can say which $Success you want to use by putting in a namespace, or by
setting that namespace's $Success to whatever you like.

package Muddle;
use Frappe;

our $Success = 'Successfully muddled!';
print $Frappe::Success; # Shows 'Cheers!'
print $Success; # Shows 'Successfully muddled!'

> trn() sounds great, if you want to bring all of Qt into a mod_perl
> application, except it doesn't address the question either. What's so hard
> about having localized versions of Cliche.pm, or reading in the localized
> definitions in a file?

I don't think you will want to bring Qt into a mod_perl application either...
just a hunch.

> Or am I missing something?

I am probably missing even more. I haven't written any localized apps (yet),
and so my advice is probably worth significantly less than two cents.

One thing comes to my mind, however. It really wouldn't be too difficult to
write a trn() function, and there probably is something out there on CPAN as
it is.

Jonathan Gardner
jgardn at alumni.washington.edu


To: Jonathan Gardner <jgardn at alumni.washington.edu>
From: m3047 at inwa.net (Fred Morris)
Subject: Re: SPUG: My two perl gizmos (CPAN module paralysis)
Cc:
Bcc:
X-Attachments:
Message-Id: <v02130500ba2aabc3f7a7@[216.173.211.38]>

>On Friday 20 December 2002 09:02 pm, Fred Morris wrote:
>> The point of the exercise is to have a $success which is not dependent on
>> the namespace, or doesn't have to be declared into particular namespaces.
>>
>> >$main::Success = "Done!";
>> >$Frappe::Success = "Cheers!";
>> >$SomeModule::Stir::Success = "Mixed!";
>>
>> So, my namespace is Muddle, and I ask for the value of $Success. What
>> happens?
>>
>
>It will say you don't have $Success defined. Depending on whether or not you
>are use'ing strict, it will raise and error.

Yah. And what I want is a pool of constants (or actually transformations,
but it's ok to simplify) which override. In what I've got,
cliche('Muddle.Success') -> "Done!", cliche('Muddle.Frappe.Success') ->
"Cheers!", etc. cliche('SomeModule.Fry.Success') -> "Done!",
cliche('SomeModule.Frappe.Success') -> "Cheers!".

Clear as mud? Think about how DNS works... or is supposed to work, since
there are a lot of faulty implementations and misconfigured systems out
there.

This isn't theoretical, either. I've got the module written, and I'm using
it in a rather large mod_perl app.

--

Fred Morris
m3047 at inwa.net





More information about the spug-list mailing list