[18783] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 951 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 21 18:05:51 2001

Date: Mon, 21 May 2001 15:05:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990482717-v10-i951@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 21 May 2001     Volume: 10 Number: 951

Today's topics:
        ANN: GXML and gxml2html 2.0: generic XML transformation <josh@spies.com>
    Re: Array slice: how about the remainder? nobull@mail.com
    Re: Array slice: how about the remainder? <godzilla@stomp.stomp.tokyo>
    Re: Array slice: how about the remainder? <godzilla@stomp.stomp.tokyo>
    Re: Array slice: how about the remainder? <godzilla@stomp.stomp.tokyo>
    Re: Array slice: how about the remainder? <krahnj@acm.org>
        Autosplit -a flag and trailing null fields <allenjo5@mail.northgrum.com>
    Re: Closure: which variable does it refer to? <joe+usenet@sunstarsys.com>
    Re: Closure: which variable does it refer to? <ilya@math.ohio-state.edu>
    Re: Environment <sgkay@btinternet.com>
    Re: Handling JPEGs without modules <elijah@workspot.net>
    Re: Help: using constants from inherited parent class (Kai Henningsen)
        how to get the access_log file name in a program <twhu@lucent.com>
    Re: How to match the password created in Linux shadow s (Joseph Chen)
    Re: image_button and onClick??? (Randal L. Schwartz)
    Re: image_button and onClick??? <AgitatorsBand@yahoo.com>
    Re: image_button and onClick??? <flavell@mail.cern.ch>
    Re: image_button and onClick??? (Randal L. Schwartz)
    Re: Initialisation of object <abe@ztreet.demon.nl>
        Mail::Mailer ignores my "From" setting <dn131@yahoo.com>
    Re: Mail::Mailer ignores my "From" setting <dn131@yahoo.com>
    Re: Making a C structure persistent for use in perl. nobull@mail.com
    Re: module for combinatorics? (partitions etc) <EUSWMCL@am1.ericsson.se>
    Re: module for combinatorics? (partitions etc) (Craig Berry)
    Re: module for combinatorics? (partitions etc) <EUSWMCL@am1.ericsson.se>
    Re: My senior project is "done" <lmoran@wtsg.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 21 May 2001 13:34:02 -0600
From: Josh Carter <josh@spies.com>
Subject: ANN: GXML and gxml2html 2.0: generic XML transformation and XML->HTML conversion
Message-Id: <josh-0B78C5.13340221052001@news.uswest.net>

Hi all,

I'm pleased to announce a new and hugely improved version of
gxml2html, and a new module called GXML.pm. See:

http://multipart-mixed.com/xml/

These tools are a template-based system for transforming XML and/or
converting XML into HTML. You can start with XML source in most any
format, and create templates that define the formatting of output.
GXML is similar in purpose to XSL[T], but is much simpler, while still
being applicable to a wide variety of tasks.

For those that have tried previous versions of gxml2html, here are
some of the new features in 2.0:

* Core GXML engine is now a module. You can generate stuff dynamically
  (e.g. from CGIs), and use it from any application.
* New GXML commands with some of XSL's best features: ifexists,
  ifequals, and foreach. Very huge bonus for many tasks.
* You can specify handler methods for variables and templates which
  the engine can't otherwise match. This lets you dynamically generate
  templates or variable values.
* You can add callbacks to start and end tags of given elements, and
  change GXML's handling of those elements dynamically.
* Complete documentation, more examples, and GXML test suite.

Plus lots of other new stuff. All the docs are online, so give them a
look. Please email me with any questions, comments, and bug reports.

Best regards,
Josh


------------------------------

Date: 21 May 2001 18:50:41 +0100
From: nobull@mail.com
Subject: Re: Array slice: how about the remainder?
Message-Id: <u9snhya8we.fsf@wcl-l.bham.ac.uk>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> John Lin wrote:

> > The solution I can think of is:
>  
> > my @not_chosen = grep {!grep($_,@chosen)} 0..$#array;
> > my @stay_home = @array[@not_chosen];
> 
> Have you tested this method?

No clearly he hasn't.  I have corrected his error in another branch of
this thread.

> Consider posting precise and exact parameters in the future.
> Not doing so is quite illogical.

Precise and exact is probably asking too much.  Self-consistant would
probably be enough.
 
> You will find my test script below my signature

In a plaintext message a signature starts at the sig-sep "\n-- \n" and
extends to the end of the document.  Your document contains no sig-sep
and hense no signature.  If the thing that looks superficially like a
sig-sep "\n--\n" were a real sigsep then the test script would _be_
your signature.

I have explained this to you in the past but given your recent
improvements I thought I'd have another go.

> to be relatively quick and efficient.

Relative to what John tried maybe, not compared to what you could have
offered.

> my (@stay_home);
> my (@array) = (1 .. 20);
> my (@chosen) = (0, 2, 4, 6, 8, 10, 12, 14, 16, 18);
> foreach $chosen (@chosen)
>  {undef ($array[$chosen]); }

This can be more simply written using a slice:

undef @array[@chosen];

> foreach $stay_home (@array)
>  { 
>   if (defined ($stay_home))
>    { push (@stay_home, $stay_home); }
>  }

This can be more simply written using a grep:

my @stay_home = grep { defined } @array;

BTW: You forgot to declare $chosen, use strict would have warned you
about this.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Mon, 21 May 2001 11:10:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Array slice: how about the remainder?
Message-Id: <3B095A33.949D7636@stomp.stomp.tokyo>

Mark Jason Dominus wrote:
 
> John Lin wrote:

(snipped)

> >my @array = <NAMELIST>;
> >my @chosen = (0,3,5,7,21,35,63,66,68);
> >my @go_picnic = @array[@chosen];  # those who are chosen go picnic
> >my @stay_home = @array[???????];  # those who are not chosen stay home
 
> I don't know if this is worth doing:
 
>         my @stay_home = @array;
>         for (reverse @chosen) {
>           splice @stay_home, $_, 1
>         }
 
> It's quadratic time in principle, but it's quite different from the
> other proposed solutions, and might nevertheless be faster than they
> are for practical cases.


Playing the part of a "what if geek" as is common here,
yours is decent code. However, in keeping with your stated
"practical case" situation, you need to add a qualified
parameter. Array @chosen must be in sorted ascending order
for your method to function correctly. This may not be the
case when dealing with personal name lists.

Not stating clear and concise parameters as needed, 
as I often say, is quite illogical.

Godzilla!


------------------------------

Date: Mon, 21 May 2001 11:17:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Array slice: how about the remainder?
Message-Id: <3B095BB9.3505785A@stomp.stomp.tokyo>

nobull@mail.com wrote:
 
> Godzilla! wrote:
> > John Lin wrote:
 
(massive snippage)

> > You will find my test script below my signature
 
> In a plaintext message a signature starts at the sig-sep "\n-- \n" and
> extends to the end of the document.  Your document contains no sig-sep
> and hense no signature.  If the thing that looks superficially like a
> sig-sep "\n--\n" were a real sigsep then the test script would _be_
> your signature.


Ya know, you are so anal retentive, if your head wasn't
such an effective plug, there is every likelihood you
would suck in our entire universe.

Godzilla!


------------------------------

Date: Mon, 21 May 2001 13:43:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Array slice: how about the remainder?
Message-Id: <3B097DFD.70624EB2@stomp.stomp.tokyo>

Mark Jason Dominus wrote:

> John Lin wrote:

(some snippage)

> >my @array = <NAMELIST>;
> >my @chosen = (0,3,5,7,21,35,63,66,68);
> >my @go_picnic = @array[@chosen];  # those who are chosen go picnic
> >my @stay_home = @array[???????];  # those who are not chosen stay home

(topic is how to determine a "stay at home" list of names)
 
> I don't know if this is worth doing:
 
>         my @stay_home = @array;
>         for (reverse @chosen) {
>           splice @stay_home, $_, 1
>         }
 
> It's quadratic time in principle, but it's quite different from the
> other proposed solutions, and might nevertheless be faster than they
> are for practical cases.
 
> However, I did not benchmark.

It is wise to always question a personal perspective
on what constitutes practical cases.

At selected times during any given year, our church sponsers
a picnic. For practical cases like this, a sign-up list for
picnic attendance is on a first come, first serve basis. This
creates an unsorted list.

To determine who is attending and who is not, our church
master list of parish members, an alphabetized list, is
compared to this attendee list, resulting in an unsorted
list, as would be a practical case.

Although the originating author's scenario is most illogical,
he did indicate a "namelist" and, in keeping with reality 
to a measured degree, I have tossed together a benchmark
test for you which more closely reflects practical cases.

I say the originating author's scenario is illogical because
a comparison of two name lists would not produce an array of
element reference numbers; it would produce an unsorted array
of names. Practicality dictates different coding is needed
to deal with reality.

So, here are benchmark tests for you, which reflects reality
to a degree, but are unrealistic in using element reference
numbers instead of a comparison of a sorted name list and,
an unsorted name list.

I have added a "sort" to your code so it will function
correctly per pseudo realistic parameters rather than
ideal perfect parameters. My controls have been standardized
to present reliable comparative results.

Do enjoy.

Godzilla!
--

#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {
  'name1' =>
  'my (@stay_home);
   my @array = (billyray, bobbysue, kiralynne, loriann, nancyjoe, rubymae, velmajean);
   my @chosen = (2, 0, 3, 6, 1);
   for (@chosen)
    {undef ($array[$_]); }
   for (@array)
    { 
     if (defined ($_))
     { push (@stay_home, $_); }
    }',

  'name2' =>
  'my (@stay_home);
   my @array = (billyray, bobbysue, kiralynne, loriann, nancyjoe, rubymae, velmajean);
   my @chosen = (2, 0, 3, 6, 1);
   my @stay_home = @array;
   for (reverse sort @chosen)
    { splice @stay_home, $_, 1 }',
  } );
 }

exit;

PRINTED RESULTS:
________________


Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  5 wallclock secs ( 4.23 usr +  0.00 sys =  4.23 CPU) @ 23640.66/s
 name2:  5 wallclock secs ( 5.27 usr +  0.00 sys =  5.27 CPU) @ 18975.33/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  5 wallclock secs ( 4.23 usr +  0.00 sys =  4.23 CPU) @ 23640.66/s
 name2:  5 wallclock secs ( 5.38 usr +  0.00 sys =  5.38 CPU) @ 18587.36/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  5 wallclock secs ( 4.23 usr +  0.00 sys =  4.23 CPU) @ 23640.66/s
 name2:  5 wallclock secs ( 5.33 usr +  0.00 sys =  5.33 CPU) @ 18761.73/s


------------------------------

Date: Mon, 21 May 2001 21:02:08 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Array slice: how about the remainder?
Message-Id: <3B098263.BE1FF04C@acm.org>

John Lin wrote:
> 
> Dear all,
> 
> I've been asked a quite interesting question.
> 
> my @array = <NAMELIST>;
> my @chosen = (0,3,5,7,21,35,63,66,68);
> my @go_picnic = @array[@chosen];  # those who are chosen go picnic
> my @stay_home = @array[???????];  # those who are not chosen stay home
> 
> It's convinent to have array slice syntax to get partial of an array.
> But what about the remainder (also partial of the array)?
> 
> The solution I can think of is:
> 
> my @not_chosen = grep {!grep($_,@chosen)} 0..$#array;
> my @stay_home = @array[@not_chosen];
> 
> There must be a better way...  Could you help?

my @stay_home = <NAMELIST>;
my @chosen = (0,3,5,7,21,35,63,66,68);
my @go_picnic;

push @go_picnic, splice @stay_home, $_, 1 for sort { $b <=> $a }
@chosen;

# Or if you setup @chosen in the correct
# order to begin with

my @stay_home = <NAMELIST>;
my @chosen = (68,66,63,35,21,7,5,3,0);
my @go_picnic;

push @go_picnic, splice @stay_home, $_, 1 for @chosen;



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Mon, 21 May 2001 19:58:56 GMT
From: "John L. Allen" <allenjo5@mail.northgrum.com>
Subject: Autosplit -a flag and trailing null fields
Message-Id: <3B097380.46A5C9C4@mail.northgrum.com>

I find it annoying that the -a flag ignores trailing null fields.
It does this because it uses  split()  with no limit parameter.
As such, the -a flag is less awk-like than it could be.  If this
was deliberate, perhaps there should be a -A flag (or whatever)
to make autosplit use a -1 for the limit.

John.


------------------------------

Date: 21 May 2001 15:48:04 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <m38zjqv5zf.fsf@mumonkan.sunstarsys.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> writes:

> I wrote:
> >   {
> >     my $x = "bar";
> >     sub foo {
> >         # $x;                   # not so useless :-)
> > 	return sub {$x};
> >     }
> >   }
> > 
> >   $b = foo();

> $b references $x after the block containing $x is left.  During
> going-out-of-scope of $x the "recycling" [1] is done, since the refcount
> of $x is larger than 1 at this moment.  Hence $x becomes a new
> undefined Perl value.  So there is no problem with the
> behaviour of $b too.

Thank you for the explanation.  However I still cannot see how this 
is proper behavior.  IMHO it shouldn't make any difference whether 
or not the useless use of $x is commented out above, but it 
apparently does.

Another example:

#!/usr/bin/perl -wl
use strict;
{
  my $x = "bar";

  sub foo {

    if (@_) {
        $x if 0;        # noop ?
        return sub {$x};
    }

    return sub {$x};
  }
}

  print foo(1)->();     # bar
  print foo()->();      # undefined
  print foo(1)->();     # bar
  print foo()->();      # undefined

__END__

How is it reasonable for the foo sub to harbor two distict values
for $x?

-- 
Joe Schaefer               "Buy land.  They've stopped making it."
                                               --Mark Twain


------------------------------

Date: 21 May 2001 20:39:17 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <9ebudl$fbt$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Joe Schaefer 
<joe+usenet@sunstarsys.com>], who wrote in article <m38zjqv5zf.fsf@mumonkan.sunstarsys.com>:
> > $b references $x after the block containing $x is left.  During
> > going-out-of-scope of $x the "recycling" [1] is done, since the refcount
> > of $x is larger than 1 at this moment.  Hence $x becomes a new
> > undefined Perl value.  So there is no problem with the
> > behaviour of $b too.
> 
> Thank you for the explanation.  However I still cannot see how this 
> is proper behavior.

???

> IMHO it shouldn't make any difference whether 
> or not the useless use of $x is commented out above, but it 
> apparently does.

*This* may be a bug.

Ilya


------------------------------

Date: Mon, 21 May 2001 21:56:42 +0100
From: "Steve Kay" <sgkay@btinternet.com>
Subject: Re: Environment
Message-Id: <20010521.215605.1350573793.2156@desktop.peachy.com>

Try "perldoc -q environment"

In article <5eaO6.4758$Ju.11744347@newsserver.ip.pt>, "Nuno"
<nll@hotmail.com> wrote:

> Hello all,
> 
> How can i set an environment variable from perl like:
> 
> # export HOSTX=192.168.112.1
> 
> # run_my_perl_prog (HOSTX change to 172.xxxxx)
> 
> # set | grep HOSTX
> HOSTX=172.xxxxx
> 
> 
> Tanks in advance,
> 
> Nuno
> 
>


------------------------------

Date: 21 May 2001 20:49:19 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Handling JPEGs without modules
Message-Id: <eli$0105211637@qz.little-neck.ny.us>

In comp.lang.perl.misc, Honza Pazdziora <adelton@informatics.muni.cz> wrote:
> Michael A. Krehan <ebo_mike-antispam-remove-t@hottmail.com> wrote:
> > PROBLEM is that my hoster won't allow me to install modules. The only
> > available module is GD 1.19 which is incapable of handling JPEGs - the only
> > format I really need.
> How would the hoster know, if you install a Perl script (*.pl) or Perl
> module (*.pm)? Shouldn't your question better be rephrased as "how to
> install all those great standard modules from CPAN to nonstandard
> place, if my hoster won't do the installation for me and I obviously
> don't have permissions to write to system-wide library directories"?

Um, maybe.

I think an issue here is that all the JPEG handling code he has found
for perl requires compiling, and I suspect that the hosting site
wouldn't allow that. The Image::Magick module could do what the poster
wants, but it is a non-trivial install if ImageMagick isn't already on
the system. 

Modules that are actually built by 'make' are also more complicated
if you can only FTP in.

Elijah
------
uses pbmplus tools for his image editing


------------------------------

Date: 21 May 2001 23:24:00 +0200
From: kaih=81IMb4HHw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Help: using constants from inherited parent class
Message-Id: <81IMb4HHw-B@khms.westfalen.de>

abigail@foad.org (Abigail)  wrote on 21.05.01 in <slrn9gidbm.6rt.abigail@tsathoggua.rlyeh.net>:

> Even in an OO world, I'd like to use O_CREAT instead of Fcntl -> O_CREAT.
>
> Programmer convenience. Making 'Fcntl ->' mandatory adds *NOTHING*,
> just warm fuzzy feelings for OO pronents.

First of all, OO is really a red herring here. Not exporting stuff is a  
*namespace* decision, not an OO decision.

OO just comes in because, in Perl, it is customary to be more strict with  
namespaces when using OO. But there's no particular reason it has to be  
that way.

Now, that out of the way, the *namespace* benefit here is that two  
different modules can have two different O_CREAT symbols and not conflict.  
Sure, with O_CREAT that's rather unlikely; but certainly I do not have to  
explain that there are enough identifiers used for constants that  
sometimes, this _is_ an issue.

Making a qualifier mandatory for constant names serves exactly the same  
purpose as making it mandatory for class methods ("global functions") or  
class variables ("global variables"). In short, "package" was invented  
because that's often useful. And yes, it's not *always* useful.

Kai
-- 
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


------------------------------

Date: Mon, 21 May 2001 15:03:59 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: how to get the access_log file name in a program
Message-Id: <9ebot3$3i7@nntpb.cb.lucent.com>

I can get the server name from the Apache module via the
$r->server->server_hostname.
Is there a way to get the file name of TransferLog or CustomLog from the
Apache module?





------------------------------

Date: 21 May 2001 12:14:02 -0700
From: yen_hung@yahoo.com (Joseph Chen)
Subject: Re: How to match the password created in Linux shadow suite?
Message-Id: <bf927196.0105211114.6964be82@posting.google.com>

The reply has a misunderstanding about the statement of the problem.
Whithout the Linux shadow suite, a common practice allows the password
a user types in to be encryped and compared against the system password
of the user in order to verify the access of the user. For a password
read from the user, e.g., $passwd_read, we can do the following in
perl to verify his/her access to the system.

$salt = substr($passwd_read,0,2);
$passwd_read_and_encrypted = crypt($passwd_read,$salt);
if ($passwd_read_and_encrypted eq $user_passwd_encrypted_from_system) {
   the user has access
} else {
   the usr has no access
}

Without using the shadow suite, we can get $user_passwd_encrypted_from_system
from /etc/passwd file. It does not require a 'root' access privilege to
read this file and the above codes work!

With the shadow suite, all user passwords in /etc/passwd are moved
to /etc/shadow and the passwords in /ect/password are replaced by '*'.

To solve this password moving issue, I can read the user password 
$user_passwd_encrypted_from_system from /etc/shadow instead of
/ect/passwd. But, the major problem I could not solve is that 
the encrpyted password in /ect/shadow is longer than the password
encrypted in /etc/passwd. They have different lengths. This is
why my comparion if-statement in the above codes fails, even if
the $passwd_read is the same as the password of the user before
the password is encrypted by the shadow suite.

Is it because the shadow suite uses a different encrypton method?
And, how do I fix this problem using perl? Any help is appreciated.


Joseph Chen

P.S. I have root access to the machines I work on. So, please do not
raise the root access issue anymore.

abigail@foad.org (Abigail) wrote in message news:<slrn9gcg31.sk5.abigail@tsathoggua.rlyeh.net>...
> Joseph Chen (yen_hung@yahoo.com) wrote on MMDCCCXVIII September MCMXCIII
> in <URL:news:bf927196.0105182003.1e825283@posting.google.com>:
> ""  Dear Perl Users,
> ""  
> ""  I move a CGI program from an IBM machine to a Linux machine.
> ""  In the IBM machine, the program allows users to enter their 
> ""  login password and uses the password to match the one in 
> ""  /etc/passwd file. It works ok. But, after I move the program
> ""  to the Linux machine. The password comparison fails.
> 
> 
> Due to shadow passwords. This is a feature. It avoids security problems
> like programs from other users asking for passwords and checking them.
> A quick way to collect passwords from other people on the system.
> 
> You are not experiencing "a problem", just like a bank robber isn't
> experiencing "a problem" when facing the vault. You are both encountering
> a safety device designed to keep you out.
> 
> 
> Unless you are root, you have no business of collecting peoples passwords.
> And when you are, you shouldn't have to ask how to do it.
> 
> 
> 
> Abigail


------------------------------

Date: 21 May 2001 11:09:08 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: image_button and onClick???
Message-Id: <m1wv7ashff.fsf@halfdome.holdit.com>

>>>>> "Bryan" == Bryan Coon <bcoon@sequenom.com> writes:

Bryan> What do you think 'misc' stands for?  This is a perl question, relating
Bryan> to the image_button method found in CGI.pm, and the documentation found
Bryan> therein.  There may be other appropriate groups, but that does NOT mean
Bryan> that comp.lang.perl.MISC is inappropriate!

Actually, it does.  This is the catchall only when there aren't any
more appropriate groups.  That's what a Usenet "misc" group means.  Or
have you failed to read the Usenet manuals in
"news.announce.newusers"?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Mon, 21 May 2001 19:16:59 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: image_button and onClick???
Message-Id: <LQdO6.1272$du2.126398@news.shore.net>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: Actually, it does.  This is the catchall only when there aren't any
: more appropriate groups.  

What group would be more appropriate for discussing the perl CGI module?

--Art


------------------------------

Date: Mon, 21 May 2001 22:06:20 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: image_button and onClick???
Message-Id: <Pine.LNX.4.30.0105212204440.1130-100000@lxplus003.cern.ch>

On Mon, 21 May 2001, Scratchie wrote:

> What group would be more appropriate for discussing the perl CGI module?

If you want to discuss the module, then a group with module(s) in its
name seems appropriate.  If you want to discuss projects to be
implemented with the module, you'd be more at home on a group with CGI
in its name.  Need I say more?



------------------------------

Date: 21 May 2001 13:15:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: image_button and onClick???
Message-Id: <m1k83asbka.fsf@halfdome.holdit.com>

>>>>> "Scratchie" == Scratchie  <AgitatorsBand@yahoo.com> writes:

Scratchie> What group would be more appropriate for discussing the
Scratchie> perl CGI module?

As it applies to CGI, comp.infosystems.www.authoring.cgi.  In the pure
aspect of it being a module, in concert with other modules or
installing it or updating it or whatever, comp.lang.perl.modules.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Mon, 21 May 2001 23:48:54 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Initialisation of object
Message-Id: <qk0jgtg3915khi214mj5umcal29pgrbg5t@4ax.com>

On Thu, 17 May 2001 10:16:10 +0800, "John Lin" <johnlin@chttl.com.tw>
wrote:

> <nobull@mail.com> wrote
> > "Michael Stroeck" writes:
> > > my $msg = new ForumMessage;
> > > $msg->{
> > >                 thread_id => $cgi->param('thread_id'),
> > >                 user_id => $cgi->param('user_id'),
> > >             }
> >
> > The most direct way is:
> >
> > %$msg = (
> >          %$msg,
> >          thread_id => scalar $cgi->param('thread_id'),
> >          user_id => scalar $cgi->param('user_id')
> > );
> 
> The syntax using "Slices" may be closer to what the OP wanted.
> 
> @{$msg}{'thread_id', 'user_id'} = ($cgi->param('thread_id'), $cgi->param('user_id'));
> 
> Note that we can't use
> 
> $msg->{'thread_id', 'user_id'} = ($cgi->param('thread_id'), $cgi->param('user_id'));
> 
> although it looks better.

Well, strictly speaking the first one is also wrong.

CGI->param( 'any_field' ) provides list context whenever it can. Since
slicing provides list context, your first example _can_ go wrong.

Uri already gave the right idea:

	$msg->{ $_ } = $cgi->param( $_ )
		for qw( thread_id user_id subject body );

-- 
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona tsuJ")'


------------------------------

Date: 21 May 2001 12:02:12 -0700
From: David Wake <dn131@yahoo.com>
Subject: Mail::Mailer ignores my "From" setting
Message-Id: <9n1ypibk5n.fsf@Turing.Stanford.EDU>

When I execute the following code, the mail I receive has a default
"From" setting instead of "my@address.com".  Does anyone know how to
force Mail::Mailer to use my "From" setting to override the default?

Thanks,

David


#!/usr/bin/perl -w
use strict ;
use Mail::Mailer ;

my $mailer = Mail::Mailer->new() ;
$mailer->open({
    From    => 'my@address.com',
    To      => 'david@localhost',
    Subject => 'Test',
})
    or die "Can't open:$!\n" ;

print $mailer "This is a test" ;
$mailer->close() ;




------------------------------

Date: 21 May 2001 14:55:38 -0700
From: David Wake <dn131@yahoo.com>
Subject: Re: Mail::Mailer ignores my "From" setting
Message-Id: <9nk83a9xk5.fsf@Turing.Stanford.EDU>

Answering my own question: I needed to put

> my $mailer = Mail::Mailer->new("sendmail") ; 

instead of

> my $mailer = Mail::Mailer->new() ;

It works now.

David

David Wake <dn131@yahoo.com> writes:

> When I execute the following code, the mail I receive has a default
> "From" setting instead of "my@address.com".  Does anyone know how to
> force Mail::Mailer to use my "From" setting to override the default?
> 
> Thanks,
> 
> David
> 
> 
> #!/usr/bin/perl -w
> use strict ;
> use Mail::Mailer ;
> 
> my $mailer = Mail::Mailer->new() ;
> $mailer->open({
>     From    => 'my@address.com',
>     To      => 'david@localhost',
>     Subject => 'Test',
> })
>     or die "Can't open:$!\n" ;
> 
> print $mailer "This is a test" ;
> $mailer->close() ;








------------------------------

Date: 21 May 2001 19:21:44 +0100
From: nobull@mail.com
Subject: Re: Making a C structure persistent for use in perl.
Message-Id: <u9n186a7gn.fsf@wcl-l.bham.ac.uk>

yin_12180@yahoo.com writes:

> Here's what I am trying to do.
> 
> BACKGROUND:
> I have a perl module which creates a ternary search tree with nodes
> that are defined as C structures.
> 
> The function that creates the tree returns a scalar reference of the
> tree to perl.
>
> The final size of the search tree is 200 megabytes in RAM.

Are you saying that Perl sees a reference to single 200Mb scalar?
That's probably not good.
 
> I do have enough RAM to avoid paging into virtual memory.

Trying to out-smart the OS's VM mechanism is usually a mistake.
Better to work with it rather than against.

> The tree takes about 5 minutes to build.
> 
> WHAT I WANT TO DO:  Due to the overhead of building the tree.  I want
> to "freeze" the tree in RAM space and have the tree be persistent in
> memory (not hard disk) for use by other perl programs.

Assuming this is Unix you should probably need to look into the mmap()
function in C.  This has nothing to do with Perl.  If multiple
processes mmap() the same file they are actually sharing the same
memory.

Note: if possible your structure should not contain any absolute
memory pointers as it is unwise to rely on MAP_FIXED.

> Second, I could write a method in the C module to write the entire
> data structure to disk, but I didn't want to incur the overhead of
> reading the array from disk every time I need to traverse the tree.

With mmap() the OS takes care of this.

> Any additional ideas or thoughts would be appreciated.

I think you should go elsewhere (maybe comp.unix.programmer) to learn
about mmap().

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Mon, 21 May 2001 14:27:52 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3B095E28.411E6026@am1.ericsson.se>



Drew Krause wrote:
> 
> I'm especially interested in finding a module or algorithm which will
> return a random combination of n integers which sum to x. For example, n
> = 5 and x = 18 might return (1 1 1 5 10).

Intriguing...

This tends toward too many ones...Not trivial is it?

$x=18; # input
$n=5;  # input

$y=$x;
$i=0;
$sum=0;

while ($i<$n-1) {
  $i++;
  $y=$x-$sum-$n+$i; # deduct enough to make room for remaining integers
  $c=int(rand $y)+1;
  print "$c\n";
  $sum+=$c;
}
$c=$x-$sum;
print "$c\n";


------------------------------

Date: Mon, 21 May 2001 20:31:49 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <tgiuplli18r4d4@corp.supernews.com>

Drew Krause (drkrause@mindspring.com) wrote:
: I'm especially interested in finding a module or algorithm which will
: return a random combination of n integers which sum to x. For example, n
: = 5 and x = 18 might return (1 1 1 5 10).

Here's my approach:


#!/usr/bin/perl -w
# sumn - Demo of func which picks N pos ints which sum to M
# Craig Berry (20010521)

use strict;

sub findNSumToM {
  my ($n, $m) = @_;
  my @res;

  while (@res < $n - 1) {
    my $max = $m - $n + @res + 1;
    my $val = 1 + int rand $max;
    push @res, $val;
    $m -= $val;
  }

  return (@res, $m);
}

my @res = findNSumToM(5, 18);

print "5, 18 => @res\n";


-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


------------------------------

Date: Mon, 21 May 2001 17:31:14 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3B098922.B5F32CA8@am1.ericsson.se>



Drew Krause wrote:
> 
> I'm especially interested in finding a module or algorithm which will
> return a random combination of n integers which sum to x. For example, n
> = 5 and x = 18 might return (1 1 1 5 10).


I'm thinking: A random pick would be a random pick from a list of all
possible combinations. I'm also thinking that this gets into a hugh
number quickly like the classical "Traveling Salesman Problem" (try
google search if you haven't heard of it) which mortal computers can't
perfectly do in a lifetime when the number of cities the salesman must
visit gets just a little large (like maybe 25) -- or in this case, if n
and x get large. Therefore I'm wondering if there may be many
algorithms, like those offered by several here, that might be
acceptable, but all with a certain bias and not truly random.


------------------------------

Date: Mon, 21 May 2001 16:42:30 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: My senior project is "done"
Message-Id: <savigtc4qfbfp69ah669rbeq983hft3kgq@4ax.com>

On Mon, 21 May 2001 02:35:08 GMT, "Daniel Berger"
<djberg96@hotmail.com> wrote wonderful things about sparkplugs:

SNIP
>
>1) use -w
>2) use strict
>
SNIP

Seems to have mentioned this (recently?) on his page at the very
bottom:


Current Problems: 

The most pressing problem, and one that I absolutely MUST address
before posting a pointer to this URL/paper on the Usenet newsgroup
comp.lang.perl.misc, is the lack of the "use strict" directive in the
Collection Side perl script. Since I did not include the "use strict"
directive, I was able to implicitly declare variables. This is a bad
thing, since if I misspell a variable name, that introduces a bad bug
(which did happen more times than I care to admit). Including "use
strict" would mean that I would have to go back into my code and
declare all my variables. 


Good for him... No mention of -w though.
--
BSOD? In my day we didn't have 0000FF!
lmoran@wtsg.com


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 951
**************************************


home help back first fref pref prev next nref lref last post