[18787] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 955 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 00:05:54 2001

Date: Mon, 21 May 2001 21:05:13 -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: <990504313-v10-i955@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
    Re:  Help: Can't use correctly File:Find in perl 64.158.66.163 [dontbother]
    Re: Array slice: how about the remainder? <joe+usenet@sunstarsys.com>
    Re: Array slice: how about the remainder? <godzilla@stomp.stomp.tokyo>
        checking installed modules <yungp@netvigator.com>
    Re: garbage collection in perl (Joe Smith)
    Re: Hash: keys to variable names, or variable names to  <uri@sysarch.com>
        HELP!!!! : HTTPd: malformed header Error <1@1.1>
    Re: HELP!!!! : HTTPd: malformed header Error <godzilla@stomp.stomp.tokyo>
    Re: HELP!!!! : HTTPd: malformed header Error <1@1.1>
    Re: HELP!!!! : HTTPd: malformed header Error <godzilla@stomp.stomp.tokyo>
    Re: Help: using constants from inherited parent class (Sweth Chandramouli)
    Re: How to match the password created in Linux shadow s (David Efflandt)
    Re: image_button and onClick??? (Eric Bohlman)
    Re: image_button and onClick??? <AgitatorsBand@yahoo.com>
    Re: image_button and onClick??? <AgitatorsBand@yahoo.com>
    Re: image_button and onClick??? <joe+usenet@sunstarsys.com>
    Re: Looking for a console based file selection module (Joe Smith)
    Re: module for combinatorics? (partitions etc) (Mark Jason Dominus)
    Re: non repeating random numbers <goldbb2@earthlink.net>
        passing subroutine as parameter to a function <rqian_2000@yahoo.com>
    Re: passing subroutine as parameter to a function <bkennedy99@Home.com>
    Re: Regexp to match IP Address <james@zephyr.org.uk>
    Re: SET-UP (free) <uri@sysarch.com>
        SIGHUP handler problems on FreeBSD 4.3-RELEASE running  <taboo@comcen.com.au>
        Using Perl to access MS Outlook task list? <cspurgeon@electronicink.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 May 2001 01:33:32 GMT
From: 64.158.66.163 [dontbother]
Subject: Re:  Help: Can't use correctly File:Find in perl
Message-Id: <9ecflc0ds7@enews1.newsguy.com>

> Hi,
> 
> Hope someone out there can help me.  I'm trying to do the command
> "find /a_root_directory/* -prune -type d" under Perl with the
> File:find module to get a listing of 1st level sub-directories ONLY (I
> don't want to see any files or files within these sub-directories). 
> I've haven't been able to determine the syntax for Perl.  I've used
> the File::Find::prune=1 but don't seem able to list the directories
> which are underneath the a_root_directory.  Any help would be greatly
> appreciated.  Thank you.

If I'm understanding what you're asking for, then using a combination of opendir() and readdir() should do this quite nicely.

So, if the directory was /home/me and you wanted all the directories contained directly beneath it, you could do:

opendir(D, "/home/me") or die("Couldn't open /home/me for reading\n");
my @entries = readdir(D);

foreach (@entries) {
  if (-d $_) {
    # code here to record the directories
  }
}

closedir(D);

In this case, File::Find seems like overkill.

fs


==================================
Poster's IP address: 64.158.66.163
Posted via http://nodevice.com
Linux Programmer's Site


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

Date: 21 May 2001 21:58:15 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Array slice: how about the remainder?
Message-Id: <m3pud2taa0.fsf@mumonkan.sunstarsys.com>

nobull@mail.com writes:

> "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> 
> > 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];

Actually, that's not the same as Godzilla's foreach loop.  undef() 
will treat the slice as if it were in a scalar context, and so only 
the last element actually gets undef'd:

  % perl -wle '@a = "a".."z"; undef @a[0..25]; print @a'
  Use of uninitialized value in print at -e line 1.
  abcdefghijklmnopqrstuvwxy

-- 
Joe Schaefer    "It is better to be feared than loved, if you cannot be both."
                                               -- Niccolo Machiavelli


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

Date: Mon, 21 May 2001 20:01:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Array slice: how about the remainder?
Message-Id: <3B09D69B.F2AFCFA1@stomp.stomp.tokyo>

Joe Schaefer wrote:
 
> John Lin  wrote:
 
> > 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)?
 
>   require 5.006;
>   my @stay_home = @array;
>   delete @stay_home[@chosen];
 
For your entertainment, I selected four methods from this thread
and ran benchmark tests. At first glance, it appears all methods
are equally efficient. However, they are not. With a mild increase
in array size, methods other than yours and mine, become more
inefficient, especially grep methods. Method name2 does pretty
good except for its reliance on a sorted ascending order array.

Yours is name3 in my tests. I added several lines to equalize
controls. Your method leaves undefined elements where others
do not. However, even with a few extra lines of code, your
method still performs very well.

I am not so sure changing your array to a string then removing
multiple spaces is good control quality but, this would be a rather
common method of dealing with this, unless creation of an array
free of undefined elements was an absolute must.

Still, for everyday circumstances, this problem presented would
be two arrays of names to compare. This reduces this question
to a simple FAQ question often asked; comparing arrays.

Godzilla!
--

Your method is name3. Mine is name1.



#!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, cecilroy, bobbysue, charly, crutcher,
                davidjoe, fayeann, gunther, herbertweldon, kiralynne,
                jimmyray, larry, loriann, marylou, nancyann,
                nancyjoe, rubymae, velmajean, zelma);
   my (@chosen) = (2, 0, 3, 6, 1, 18, 14);
   foreach (@chosen)
    {undef ($array[$_]); }
   for (@array)
    { 
     if (defined ($_))
      { push (@stay_home, $_); }
    } ',

  'name2' =>
  'my @array = (billyray, cecilroy, bobbysue, charly, crutcher,
                davidjoe, fayeann, gunther, herbertweldon, kiralynne,
                jimmyray, larry, loriann, marylou, nancyann,
                nancyjoe, rubymae, velmajean, zelma);
   my (@chosen) = (2, 0, 3, 6, 1, 18, 14);
   my (@stay_home) = @array;
   for (reverse sort @chosen)
    { splice @stay_home, $_, 1 }',

  'name3' =>
  'my @array = (billyray, cecilroy, bobbysue, charly, crutcher,
                davidjoe, fayeann, gunther, herbertweldon, kiralynne,
                jimmyray, larry, loriann, marylou, nancyann,
                nancyjoe, rubymae, velmajean, zelma);
   my (@chosen) = (2, 0, 3, 6, 1, 18, 14);
   my (@stay_home) = @array;
   delete @stay_home[@chosen];
   my  ($test) = "@stay_home";
   $test =~ s/^\s+//;
   $test =~ s/\s+/ /g;',

  'name4' =>
  'my @array = (billyray, cecilroy, bobbysue, charly, crutcher,
                davidjoe, fayeann, gunther, herbertweldon, kiralynne,
                jimmyray, larry, loriann, marylou, nancyann,
                nancyjoe, rubymae, velmajean, zelma);
   my (@chosen) = (2, 0, 3, 6, 1, 18, 14);
   my (@stay_home) = @array;
   delete @stay_home[@chosen];
   @stay_home = grep defined, @stay_home;',
  } );
 }

exit;

PRINTED RESULTS:
________________

Run One:

Benchmark: timing 100000 iterations of name1, name2, name3, name4...
 name1:  9 wallclock secs ( 8.73 usr +  0.00 sys =  8.73 CPU) @ 11454.75/s
 name2:  9 wallclock secs ( 8.85 usr +  0.00 sys =  8.85 CPU) @ 11299.44/s
 name3:  9 wallclock secs ( 8.89 usr +  0.00 sys =  8.89 CPU) @ 11248.59/s
 name4:  8 wallclock secs ( 8.68 usr +  0.00 sys =  8.68 CPU) @ 11520.74/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2, name3, name4...
 name1:  9 wallclock secs ( 8.79 usr +  0.00 sys =  8.79 CPU) @ 11376.56/s
 name2:  9 wallclock secs ( 8.95 usr +  0.00 sys =  8.95 CPU) @ 11173.18/s
 name3:  9 wallclock secs ( 8.95 usr +  0.00 sys =  8.95 CPU) @ 11173.18/s
 name4:  9 wallclock secs ( 8.74 usr +  0.00 sys =  8.74 CPU) @ 11441.65/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2, name3, name4...
 name1:  9 wallclock secs ( 8.73 usr +  0.00 sys =  8.73 CPU) @ 11454.75/s
 name2:  9 wallclock secs ( 9.06 usr +  0.00 sys =  9.06 CPU) @ 11037.53/s
 name3:  9 wallclock secs ( 8.85 usr +  0.00 sys =  8.85 CPU) @ 11299.44/s
 name4:  9 wallclock secs ( 8.73 usr +  0.00 sys =  8.73 CPU) @ 11454.75/s


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

Date: Tue, 22 May 2001 09:44:41 +0800
From: "yungp" <yungp@netvigator.com>
Subject: checking installed modules
Message-Id: <9ecgaj$pq214@imsp212.netvigator.com>

Hi,

I was wondering is there any command that I can type in Perl to check what
modules (ie LWP, HTML parser, etc..) which I have installed already.

Thanks

Peter




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

Date: Mon, 21 May 2001 23:04:29 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: garbage collection in perl
Message-Id: <9ec6tt$2k7k$1@nntp1.ba.best.com>

In article <1etmdvk.s7krfqkq8lgoN%kpreid@attglobal.net>,
Kevin Reid <kpreid@attglobal.net> wrote:
>M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>> >  my $var if 0;
>I know almost nothing about Perl's internals, so please excuse me if
>this suggestion is inapplicable,  but what if the run-time effect of
>"my" is, at compile time, moved "before" any conditional that is not
>also a scope? For example,
>
>  my $var if 0;
>
>becomes
>
>  my $var;
>  <nothing> if 0;
>and
>
>  my $var = 'some_initial_value';

That interferes with the current, documented behavior: "A private
variable's scope does not start until the statement _after_ its
declaration."  

	$var = 0;		# Global var or previous lexical scope
	{
	  my $var = $var+1;	# Get old val, add 1, store in new variable.
	  ...			# Work with incremented value
	}


--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Tue, 22 May 2001 03:40:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hash: keys to variable names, or variable names to keys?
Message-Id: <x7lmnq6og1.fsf@home.sysarch.com>

>>>>> "KP" == Koos Pol <koos_pol@nl.compuware.com.NOJUNKMAIL> writes:


  KP> I am positive this code does not run as written here. But I hope I
  KP> demonstrated how you can keep the data and logic seperated.
  >> 
  >> no, you converted one problem for another. eval is not meant to solve
  >> the symbolic ref issue. use hashes and data structures instead.
  >> 
  >> uri

  KP> I am not really sure I understand what the problem is I
  KP> introduced. Care to elaborate?

eval is dangerous. period. it should only be used if there is
absolutely no other way to do something. managing a list of restrictions
can be done in a variety of ways that do not involve eval. you can keep
a simple list of data structures which define the operation, limits,
etc. and call a sub through a dispatch table to do the check. very
simple to create, manage and maintain and no danger of eval.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Tue, 22 May 2001 03:01:49 GMT
From: G3CK0 <1@1.1>
Subject: HELP!!!! : HTTPd: malformed header Error
Message-Id: <MPG.157392b91f5e0bea989680@news-server.wi.rr.com>

I am a newbie to Perl and I am trying to install a form processing 
script on a server. Everything works great except that at the bottom of 
the page I get:

500 Server Error
The server encountered an internal error or misconfiguration and was 
unable to complete your request.
Please contact the server administrator and inform them of the time the 
error occurred , and anything you might have done that may have caused 
the error.

Error: HTTPd: malformed header from script /cgi/ennyfrms.cgi 

The script processes the input and brings up a preview page and that 
works, but that error message is at the bottom of the page. I wanna get 
that off of there!

I have looked around and it seems to be a problem with the Content-type 
line in most cases...however the author does not offer any support. Can 
any of you Perl Gurus look this over and tell me if this looks good? 
These are the first lines after the shebang in the ennyfrms.cgi file.


	if (-s "sets/gmtset.pl") {require "sets/gmtset.pl";} else {print 
"Content-type: text/html\n\n"; print "Missing/Bad Path to GMTime file
\n"; exit;}

	if (-s "sets/enyfrmset.pl") {require "sets/enyfrmset.pl";} else 
{print "Content-type: text/html\n\n"; print "Missing/Bad Path to Config 
file\n"; exit;}


TIA




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

Date: Mon, 21 May 2001 20:16:26 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: HELP!!!! : HTTPd: malformed header Error
Message-Id: <3B09DA0A.F69F8081@stomp.stomp.tokyo>

G3CK0 wrote:

(various snippage)

> 500 Server Error
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.

> Error: HTTPd: malformed header from script /cgi/ennyfrms.cgi
 
> I have looked around and it seems to be a problem with the Content-type
> line in most cases...
 
>         if (-s "sets/gmtset.pl") {require "sets/gmtset.pl";} else {print
> "Content-type: text/html\n\n"; print "Missing/Bad Path to GMTime file
> \n"; exit;}
 
>         if (-s "sets/enyfrmset.pl") {require "sets/enyfrmset.pl";} else
> {print "Content-type: text/html\n\n"; print "Missing/Bad Path to Config
> file\n"; exit;}


If you read those if conditionals very carefully, you will
note there is nothing indicating a content type is actually
being printed within your script. Look elsewhere for the
true origin of your problem.

Godzilla!


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

Date: Tue, 22 May 2001 03:28:46 GMT
From: G3CK0 <1@1.1>
Subject: Re: HELP!!!! : HTTPd: malformed header Error
Message-Id: <MPG.15739909a7677635989681@news-server.wi.rr.com>

Ok...what are some possible causes of this message? Could it be a 
problem on my webhost's end? I didnt touch the code and I would assume 
the author wouldnt distribute bad code. Any thoughts would be greatly 
appreciated.

TIA

In article <3B09DA0A.F69F8081@stomp.stomp.tokyo>, 
godzilla@stomp.stomp.tokyo says...
> G3CK0 wrote:
> 
> (various snippage)
> 
> > 500 Server Error
> > The server encountered an internal error or misconfiguration and was
> > unable to complete your request.
> 
> > Error: HTTPd: malformed header from script /cgi/ennyfrms.cgi
>  
> > I have looked around and it seems to be a problem with the Content-type
> > line in most cases...
>  
> >         if (-s "sets/gmtset.pl") {require "sets/gmtset.pl";} else {print
> > "Content-type: text/html\n\n"; print "Missing/Bad Path to GMTime file
> > \n"; exit;}
>  
> >         if (-s "sets/enyfrmset.pl") {require "sets/enyfrmset.pl";} else
> > {print "Content-type: text/html\n\n"; print "Missing/Bad Path to Config
> > file\n"; exit;}
> 
> 
> If you read those if conditionals very carefully, you will
> note there is nothing indicating a content type is actually
> being printed within your script. Look elsewhere for the
> true origin of your problem.
> 
> Godzilla!
> 


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

Date: Mon, 21 May 2001 20:41:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: HELP!!!! : HTTPd: malformed header Error
Message-Id: <3B09DFF4.F3763744@stomp.stomp.tokyo>

G3CK0 wrote:
 
> Ok...what are some possible causes of this message? Could it be a
> problem on my webhost's end? I didnt touch the code and I would assume
> the author wouldnt distribute bad code. Any thoughts would be greatly
> appreciated.

A good approach would be to check to discover if
your script is actually printing a content type,
as I suggested previously.

This is not too difficult; simply look for a
content type print within your script.

Godzilla!


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

Date: Tue, 22 May 2001 03:49:49 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: Help: using constants from inherited parent class
Message-Id: <xllO6.16416$G5.3359666@news1.rdc1.md.home.com>

In article <slrn9gja2p.jl8.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>Ah, I see. So, the argument is "I don't export anything, cause despite
>Perl giving you all means of saying what you want to import, and despite
>MI being relatively rare (not to mention 99% of the OO module out there
>are a frigging pain in the ass to use in MI anyway) I will assume you are
>going to mess up and use something else making a name space clash.
>Nanananana".
>
>Very Perl-like.
	Exactly.  OO _isn't_ very Perl-like.  Grafting OO into the
Perl world causes some problems, either in terminology or implementation.
As you point out in your last reply to my last post in this thread, there
isn't a single thing that prevents a person from exporting constants from
an "OO" package and changing the underlying implementation; since OO 
doesn't deal with namespaces, however, doing so just doesn't grok in OO
terminology.  A clever programmer could realize (as I think you do) that
Exporter _does_ provide encapsulation, and that, if you wanted to look at
it that way, the "use" syntax for importing a var/constant is really just
another accessor method for a class attribute.  OO isn't anything really
unique or revolutionary; it's just a set of guidelines for how to do things
in a structured manner so that you and others might be able to understand
the underlying logic better.  _Everything_ you can do in OO can be done in
a non-OO way, and in many cases it can even be done more easily.
Unfortunately, for most people, it's not that easy to see how the more
traditional equivalent acts in an OO-ish manner, so there's more of a 
chance for the programmer to get confused and violate encapsulation and
cause Bad Things to happen.  That's why the OO interface in Perl uses a
fairly consistent notation; so that people can see the OO structures more
easily.  Importing/exporting _can_ do the same thing; it just hides the
logic.
	All of which is a long, convoluted way of saying "It's not
the OOP way", which the original post had asked not be given as an answer.
But it's true: the only reason "OO" exists is to help you think your way
around a particular programming problem, and importing/exporting just 
happen to not be part of the notation/language used to describe that way
of thinking by those particular people.

	-- Sweth, who quite regularly mixes OO and non-OO conventions
and thus probably has no room to talk here.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: Tue, 22 May 2001 01:28:07 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: How to match the password created in Linux shadow suite?
Message-Id: <slrn9gjg56.a7o.see-sig@typhoon.xnet.com>

On 21 May 2001 12:14:02 -0700, Joseph Chen <yen_hung@yahoo.com> wrote:
> 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);

The above is a common misconception for some reason.  Using part of a
crypted password for salt to check a password fails for MD5 passwords.  
Using the whole crypted password as salt works for both DES and MD5
passwords.  So drop the above and for the below simply use:

if (crypt($passwd_read,$crypted_passwd) eq $crypted_passwd) {
    # the user has access
} else {
    # bad passwd
}

But this assumes that shadow uses your standard system crypt() function.  
Maybe when referring to shorter (DES) and longer (MD5) passwords you are
comparing different systems with different crypt(), instead of the same
system with and without shadow.

> 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.

It may be using MD5 passwords (if they begin with $).  But since your
password checking algorythm is broken (chopping crypted password as salt),
your password check would most certainly fail.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 22 May 2001 01:50:42 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: image_button and onClick???
Message-Id: <9ecgli$16c$4@bob.news.rcn.net>

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

In comp.*, ".misc" actually has a very precise meaning, namely that the 
group is for topics that are related to the previous part of the name (in 
this case comp.lang.perl, referring to the *comp*uter *lang*uage Perl), 
but at the same time are not related to the topics of other groups that 
share the same root name (e.g. comp.lang.perl.tk is for Perl-Tk topics, 
which therefore don't belong in this group).



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

Date: Tue, 22 May 2001 01:55:08 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: image_button and onClick???
Message-Id: <0GjO6.1318$du2.131378@news.shore.net>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
:>>>>> "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.

Obviously, but the OP's question had nothing to do with CGI (the
interface). He was trying to get CGI (the perl module) to do what he
wanted it to. 

:  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.

OK, gotcha. But his question wasn't about any of those things. He was
having problems getting the CGI module to do what he wanted. Given that
it's a commonly-used standard module, that doesn't seem signficantly more
off-topic that if he were having trouble getting "map" to do what he
wanted, or if he were having trouble with a complicated regex.

It seems like lots of questions about specific modules get answered in
this group; questions about how they work, not questions about how to
install them, or update them, or get them to work with other modules.  
Perhaps I'm wrong... I haven't actually counted, but it seems like
questions about specific modules that aren't, say, related to CGI or
JavaScript (hot-button topics) get answered (or not, as the case may
be) without any great outcry of "This is off-topic! Take it to another
group!"

--Art


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

Date: Tue, 22 May 2001 02:01:56 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: image_button and onClick???
Message-Id: <oMjO6.1319$du2.131378@news.shore.net>

Bryan Coon <bcoon@sequenom.com> wrote:
: Netscape does not work with this code. :P

: IE has no problem.

That makes it sound like it's a JavaScript and/or HTML problem. There are
lots of incompatibilites between the two browsers. I would suggest coding
the HTML/JavaScript by hand until it does what you want. Then, if you
can't get the CGI module's built-in methods to return that working code,
simply use "print" to generate it "manually". Personally, I usually wind
up printing most of my HTML and headers "by hand" even when I'm using
CGI(':cgi') to parse the input, since the CGI module invariably winds up
doing something I don't expect that produces unwanted results.

HTH,

--Art


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

Date: 21 May 2001 23:10:56 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: image_button and onClick???
Message-Id: <m3eltit6wv.fsf@mumonkan.sunstarsys.com>

Scratchie <AgitatorsBand@yahoo.com> writes:

> It seems like lots of questions about specific modules get answered in
> this group; questions about how they work, not questions about how to
> install them, or update them, or get them to work with other modules.  
> Perhaps I'm wrong... I haven't actually counted, but it seems like
> questions about specific modules that aren't, say, related to CGI or
> JavaScript (hot-button topics) get answered (or not, as the case may
> be) without any great outcry of "This is off-topic! Take it to another
> group!"

Multiple Choice Pop Quiz:

I use a standard perl module that spits out "propah English".  Yet 
some 4.7 year old kid I know objects to the spelling of "cat" in 
the output.  For the moment, he says it should be "kat", but two days
ago he told me it was spelled "qat", and yesterday he didn't think
it could be spelled at all.

How should I debug this problem?

1)  Blame perl for this problem and ask for help some 
    newsgroup in the comp.lang.perl* heirarchy. Then firmly
    refuse advice to look elsewhere for an answer.

2)  Ask the 4.7 year old to explain what it doesn't like about
    the spelling, and look for help spelling "cat" in a newsgroup 
    that discusses "propah English".

3)  Ask some elder siblings of the 4.7 year old what they think about
    the spelling. Determine that the 4.7 year old is retarded, and ask
    for help in a group about "communicating with mentally challenged 
    4.7 year olds".

4)  Accept that it is a problem with the youngster's interpretation
    of the module's output, and decide to use "less propah English" 
    in order to communicate with the 4.7 year old. Ask here about how 
    to override the appropriate method, perhaps by subclassing it.

5)  Stop wasting time on 4.7 year olds.


Cheat Sheet:

1) Killfile
2) OK
3) OK
4) OK
5) $score++

-- 
Joe Schaefer        "What kills a skunk is the publicity it gives itself."
                                               -- Abraham Lincoln


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

Date: Tue, 22 May 2001 01:05:01 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Looking for a console based file selection module
Message-Id: <9ecdvt$2o4q$1@nntp1.ba.best.com>

In article <9e304t$bc3$1@kermit.esat.net>, Andrew <andrew@mvt.ie> wrote:
>Hi,
>
>I'm trying to find a module which will give a console based file selector /
>directory browser.  I've checked on CPAN, and found Tk based solutions
>(FileDialog, for example), but I'm looking for a console based equivalent of
>the functionality it offers.

What do you mean by "console based"?

There are user interfaces based on the 'cursed' library (24 rows of 80
columns, VT100 or full-screen MS-DOS window) and there are user interfaces
that use a GUI (Motif on X, Tk on X, MS-Windows).

Do you mean the things that MS-DOS programs used to do way back before
Windows-3.1 was invented?
	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Tue, 22 May 2001 03:47:59 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3b09e161.1626$3b@news.op.net>

In article <3B098922.B5F32CA8@am1.ericsson.se>,
William Cardwell  <EUSWMCL@am1.ericsson.se> wrote:
>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"

This is irrelevant.  Consider the problem of shuffling an array of
(1...$n).  The number of different permutations is exponential, and in
fact is larger than the number of partitions that the original author
was asking for.  Nevertheless, producing one at random is very easy.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 21 May 2001 21:52:22 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: non repeating random numbers
Message-Id: <3B09C656.AFD8F739@earthlink.net>

David Chan wrote:
> 
> On Thu, 8 Feb 2001, Jason from The Workshop wrote:
> 
> > I have need to generate a random number between 1 and 50 without
> > using a number that has already been generated.
> 
> Apologies, I haven't really looked at the code you posted, but here's
> a sub I used myself for a similar purpose; it returns the first n
> integers in random order.  Note that it would be silly to use this
> method for big numbers, but 50 is ok.
[snip]

As others have said, this is an inefficient method of shuffling numbers.
Using a more standard shuffle (eg, the algorithm in perlfaq4) will have
better results.  However, there is one problem with any shuffling method
-- you have to explicitly have an array containing all of the elements
up to the size you need.  If you want the numbers 1..10000, you need an
array with 10000 elements.  There *is* a way to eliminate this overhead!

Encrypt a counter with a small block cipher.  Obviously, since each
input value encrypts to exactly one output value, we know that no output
will appear more than once provided no input appears more than once. 
Since the counter will never be any value more than once, this
requirement is satisfied.  Of course, we need a small block cipher...

sub mksbox {
	my $M = shift;
	my $N = 1 << $M;
	my (@array,$i,$j)=(0..$N-1);
	for $i (0..$N-1) {
		$j = int rand $N;
		@array[$i,$j] = @array[$j,$i];
	}
}
sub shuffler {
	my $N = shift;
	my $M = 2; $M+=2 while( (1<<$M) < $N ); $M /= 2;
	my ($s0, $s1) = ([mksbox $M], [mksbox $M]);
	my ($s2, $s3) = ([mksbox $M], [mksbox $M]);
	my $shindex = -1;
	return sub {
		my $res;
		do {
			return undef if ++$shindex >= 65536;
			my ($lo,$hi) = ($shindex>>8,$shindex&255);
			$lo ^= $s0[$hi]; $hi ^= $s1[$lo];
			$lo ^= $s2[$hi]; $hi ^= $s3[$lo];
			$res = ($hi<<8)+$lo;
		} until( $res < $N );
		return $res + 1;
	}
}

my $shuf = shuffler 10000;
while(defined $_ = &$shuf) {
	print $_, "\t";
}
print "\n";

This uses about 1/20 as much memory as if we had shuffled 10000 elements
in the normal manner.

NB: The above code is untested.

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Mon, 21 May 2001 22:59:46 -0400
From: "Rosa Qian" <rqian_2000@yahoo.com>
Subject: passing subroutine as parameter to a function
Message-Id: <9eckiq$1if$1@netnews.upenn.edu>

Hi,

Does anyone know how to pass a subroutine as a parameter to a function,
where the subroutine also takes in paramters.

I'm trying to use the the find function:
 find({wanted => \&processTemplate, no_chdir=>1}, './general/templates');
 sub processTemplate {
    my( $login, $logout) = @_;
  ...
 }

where processTemplate takes in parameters.  How should I be calling this
subroutine as a parameter of the find() function?

Thanks,
Rosa






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

Date: Tue, 22 May 2001 03:13:28 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: passing subroutine as parameter to a function
Message-Id: <sPkO6.261$Oz4.63928@news1.rdc2.pa.home.com>


"Rosa Qian" <rqian_2000@yahoo.com> wrote in message
news:9eckiq$1if$1@netnews.upenn.edu...
> Hi,
>
> Does anyone know how to pass a subroutine as a parameter to a function,
> where the subroutine also takes in paramters.
>
> I'm trying to use the the find function:
>  find({wanted => \&processTemplate, no_chdir=>1}, './general/templates');
>  sub processTemplate {
>     my( $login, $logout) = @_;
>   ...
>  }
>
> where processTemplate takes in parameters.  How should I be calling this
> subroutine as a parameter of the find() function?

One thing you can do is create an anonymous subroutine that calls the named
one:

find( {
    wanted => sub { processTemplate("bleh", "blah") },
    no_chdir => 1
    } , './general/templates');

This ensures that processTemplate() gets called with the same parameters
each time (through the anonymous wrapper function).  Hope this helps --

--Ben Kennedy




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

Date: Tue, 22 May 2001 02:54:18 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: Regexp to match IP Address
Message-Id: <nDYJ9FJKbcC7Ewg9@obeah.demon.co.uk>

In message <tgje6rrb7arjf3@corp.supernews.com>, Craig Berry
<cberry@cinenet.net> writes
>See Friedl's _Mastering Regular Expressions_ for a great discussion of
>this very problem.  In brief, you can write a reasonably compact regex
>that will match only valid IP addresses, but it's easier to do it using
>numeric range comparisons on the dotted-quad components.

Of course, it gets more interesting when you do things like:

        $ ping 127.1

or a similar expression, where it doesn't have to be a dotted *quad* to
work, which further complicates matters.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
"You reinstall Dial-Up Networking.  The Elf screams and becomes  EBD690ECD7A1F
an icon. *** CONGRATULATIONS! *** You completed the BT Internet  B457CA213D7E6
Helpdesk training course in 15 out of a possible 9000 moves."   68C3695D623D5D


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

Date: Tue, 22 May 2001 03:53:29 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: SET-UP (free)
Message-Id: <x7elti6nuv.fsf@home.sysarch.com>

>>>>> "BM" == Bob Moose <yogibearxx@bobmoose.com> writes:

  BM> "flash" <bop@mypad.com> wrote in message news:<RlVN6.4790$eF6.368361@news20.bellglobal.com>...
  >> No one will do that for you.
  >> 
  >> You should learn to do stuff on your own.
  >> "Bob Moose" <yogibearxx@bobmoose.com> wrote in message
  >> news:4ec914b1.0105200757.2302ca2c@posting.google.com...
  >> > Can somebody set up http://www.kastle.net/products/URLredirect/
  >> > For FREE,
  >> > set up at http://www.bobmoose.com,
  >> > when done send it to http://bobmoose.com/publicftpspace,
  >> > then i will chmod it and put it in the CGI-BIN

  BM> Well, I'll ask again. Can somebody?

i will (for my definition of free which may not be yours. :)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Tue, 22 May 2001 11:23:21 +1000
From: "Kiel Stirling" <taboo@comcen.com.au>
Subject: SIGHUP handler problems on FreeBSD 4.3-RELEASE running perl v5.6.1
Message-Id: <3b09bff8$1@nexus.comcen.com.au>

Hi all,

I'm having problems with a SIGHUP handler. It works once and once only. I
can restart the deamon once without any trouble however, any following
endeavors are just ignored.

I'm installing this sig handler on a FreeBSD 4.3-RELEASE system running perl
v5.6.1

local $SIG{HUP} = \&restart;

And using this sub to restart

sub restart{
    # I've tryed with any without the following line
    local $SIG{HUP} = \&restart;
    unlink $PID_FILE; # defined as /var/run/<deamon-name>.pid
    close_all_file_handles(); # close any open file handles (sub not
included in this post)
    system "$0 @ARGV";
    exit;
}

Any idea why this is and how I can get around it?

--
Regards,

Kiel Stirling
[ Just a geek @ Comcen Internet Service ]
[ Email: geeks@comcen.com.au ]
[ Post: PO Box 336, Camperdown, 2050, NSW ]
[ Voice: +61 2 95165400 ]






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

Date: Tue, 22 May 2001 02:26:55 GMT
From: Chris Spurgeon <cspurgeon@electronicink.com>
Subject: Using Perl to access MS Outlook task list?
Message-Id: <B72F460C.15EF2%cspurgeon@electronicink.com>

Hello all...

I've been able to use Perl IMAP and LDAP modules to retrieve email and
contacts stored in a corporate client's Microsoft Outlook/Exchange system.
I'd like to also use Perl to get a hold of items users have entered into
Outlook's Task List (it's kind of a To Do list that's built into the
application).  But I can't see any way to do it (as far as I know, the task
list isn't accessible via a standard Internet protocol).  Does anyone have
any experience with this kind of thing?

TIA

Chris Spurgeon
cspurgeon@electronicink.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 955
**************************************


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