[10202] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3795 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 23 09:08:54 1998

Date: Wed, 23 Sep 98 06:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 Sep 1998     Volume: 8 Number: 3795

Today's topics:
    Re: -e file test? <jdporter@min.net>
    Re: Can't locate any modules <jdporter@min.net>
    Re: Hidden field??? (Jedi Master Yoda)
        How to implement (efficiently) an X minute cycle ? (Aharon (Al) Schkolnik)
    Re: How to implement (efficiently) an X minute cycle ? <ljz@asfast.com>
        in-place-edit regex substitution in multiple files (Dr. H.-Christian Waldmann)
    Re: in-place-edit regex substitution in multiple files <J.D.Gilbey@qmw.ac.uk>
    Re: in-place-edit regex substitution in multiple files (Mads Toftum)
    Re: MLDBM object methods <jdporter@min.net>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl Database library? <jdporter@min.net>
    Re: Perl5.005_02 build: "Thread.xs", line 465: undefine <jansen@ats.nld.alcatel.nl>
        problem retreiving cookie <guillaume@nospam.com>
    Re: Q: Picking an element from a hash (not knowing whic (Tad McClellan)
    Re: Q: Picking an element from a hash (not knowing whic <jdporter@min.net>
        Sockets question changling@erols.com
    Re: sorting Unix pathnames of unequal length by filenam <tom@smart.ruhr.de>
    Re: speed of subroutine call vs. call by function refer <jdporter@min.net>
    Re: User authorization; WAS: Hidden field??? <andin@webclub.ru>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 23 Sep 1998 08:32:01 -0400
From: John Porter <jdporter@min.net>
Subject: Re: -e file test?
Message-Id: <3608EA41.BC4BC947@min.net>

Ken Quinn wrote:
> 
> I am having a problem with the following and was hoping someone may be
> able to help.
> $a = <STDIN>; 
> chomp $a;
> if ( -e $a ) {
>...
> 
> If the file does not exist it will be made and "Made file" printed to
> screen.
> If the file does exist it is to print to screen "File already exists".
> This works fine if I use (-e filename) but when I use (-e "$a") as above
> I get "Made file \n"; printed to screen.

If you're getting different results for $a vs. "$a", then it must
depend on what $a contains.
Maybe you should print out the value of $a, as a double-check.

By the way, you should ALWAYS ALWAYS check the result of open().
E.g.:
	open(FILE,">$a") or die "Error opening '$a' for writing: $!";

-- 
John "Many Jars" Porter


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

Date: Wed, 23 Sep 1998 08:39:14 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Can't locate any modules
Message-Id: <3608EBF2.7D7BBC00@min.net>

Raza Muzaffar wrote:
> 
> Can someone please give me some advice or clue as to what possibly can be
> wrong with my perl. I cannot use any perl modules/library. For example when
> I say use File::Find, after compiling I get the error:
> 
> Can't locate the module File::Find etc
> 
> I am unable to use any modules. I have also tried to enter correct path in
> the @INC variable in the program(push(@INC,/my/library/directory) but it
> does not seem to work either.

Can you post a complete program (as short as possible!) which 
elicits the error?
Also, please provide the output you get when you type
	perl -V

Thanks!

-- 
John "Many Jars" Porter


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

Date: 23 Sep 98 11:22:43 GMT
From: yoda@dagoba.org (Jedi Master Yoda)
Subject: Re: Hidden field???
Message-Id: <slrn70hp96.7ni.yoda@dagoba.org>

On 22 Sep 1998 17:43:39 GMT, Darin McGrew <mcgrew@alumni.stanford.org> saw fit to expound:
>
>Why go through all these contortions?  Why not just use HTTP authentication
>and be done with it?

Or alternatively use some kind of proprietary server-side session
management package like BladeRunner.

JMY


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

Date: 23 Sep 1998 13:07:32 +0200
From: aharon@deltathree.com (Aharon (Al) Schkolnik)
Subject: How to implement (efficiently) an X minute cycle ?
Message-Id: <86vhmft7d7.fsf@killer.deltathree.com>


What I want to do is:

while (1)
	{set timer to expire in 10 minutes;
	 do some stuff;
	 wait for timer
	}


Now, alarm () will do the set timer part, and sleep () will do the wait
part, but the documentation says they can't be used together.

I could trap the SIGALRM from alarm (), and have the handler set a
flag, but then I'd have to loop on checking the flag - not
efficient. Is there a better way ?

TIA.



-- 
  The day is short, and the work is great,     |   Aharon Schkolnik
  and the laborers are lazy, and the reward    |   Aharon@Deltathree.com
  is great, and the Master of the house is     |   +972 2 649 1241
  impatient. - Ethics Of The Fathers Ch. 2     |


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

Date: 23 Sep 1998 07:17:18 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: How to implement (efficiently) an X minute cycle ?
Message-Id: <lt67efgjsx.fsf@asfast.com>

aharon@deltathree.com (Aharon (Al) Schkolnik) writes:

> What I want to do is:
> 
> [ ... ]
> 
> Now, alarm () will do the set timer part, and sleep () will do the wait
> part, but the documentation says they can't be used together.
> 
> I could trap the SIGALRM from alarm (), and have the handler set a
> flag, but then I'd have to loop on checking the flag - not
> efficient. Is there a better way ?

You can use `select' to do an alarm-less and sleep-less wait:

   select(undef, undef, undef, $waitTime);

Incidentally, you can also use `select' to do a wait-with-time-out on
one or more file handles, in case that's something you might be
interested in.

For more details, do a `perldoc -f select' and look at the second
usage of `select'.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 23 Sep 1998 11:59:34 GMT
From: waldmann@tiffy.fire.uni-bremen.de (Dr. H.-Christian Waldmann)
Subject: in-place-edit regex substitution in multiple files
Message-Id: <6uanr6$mc5$1@gorm.zfn.uni-bremen.de>
Keywords: regex subsititution, inplace edit, open



DEAR  PERL  COMMUNITY



MY DEPARTMENT RUNS STATISTICAL SOFTWARE AND APACHE-WEBSERVERS ON SEVERAL
PLATFORMS WITH DIFFERENT DIRECTORY STRUCTURES. I HAVE TO TRANSFER LOTS
OF FILES BETWEEN MACHINES AND ADJUST THEIR CONTENTS TO MEET HOSTSPECIFIC 
FORMATS ETC. IT'S A JOB FOR A REGEX-SUBSTITUTION TAKING EACH LINE OF EVERY
FILE IN EVERY DIRECTORY FOR AN IN-PLACE-EDIT, THAT IS RELPACE AND WRITE TO
THE SAME FILE. 

AS ANYBODY WILL SEE IMMEDIATELEY FROM THE CODE FRAGMENT BELOW, I AM WHAT YOU
CALL A "NEWBIE". ANYWAY, PLEASE DON'T DIRECT ME TO THE DOCS BECAUSE I HAVE
INDEED READ "LEARNING PERL" AND  ONLINE-DOC BUT I SEEM TO BE CONSTANTLY MISS-
SING THE MAGIC POINT. 

THE CODE BELOW MAKES UP A LIST OF DIRECTORIES FORM A "du"-STATEMENT AND 
READS THE FILENAME INTO A SCALAR (LOOP 2) AFTER CHANGING TO THAT DIRECTORY
(LOOP 1). NOW I HAVE TO PERFORM A 's/old/new/g' ON THAT FILE ( THAT IS: ANY
LINE IN IT). THIS IS WHERE THE TROUBLE STARTS. 




-----------x-- CODE START --------------------------------------------------



#!/usr/local/bin/perl

@list=`du /START-DIRECTORY/ | expand | cut -c  9-100`;

foreach $this_dir (@list) {
       
        $this_dir=~s/(.*)(\s+)/\1/g; 
        chdir($this_dir);
        opendir(DIR,$this_dir)           || die "no open on $this_dir: $!";

        foreach $name (sort readdir(DIR))   {


                                                          if (-T $name ) {
                                                             
     # HERE
     # DO : OPEN FILE, PERFORM REGEX SUBSITUTION (IN-PLACE-EDIT), CLOSE FILE 
     # HERE
                                                                         }
                                                             
                                            }
        closedir(DIR)                    || die "no close on $this_dir: $!";
                          }




      


 #   THIS FRAGMENT FITS "HERE" BUT FILE HAS 0 BYTE AFTER THE "CHANGE". MAYBE
 #   THERES SOMETHING WRONG WITH THE WAY I PERFORM THE "OPEN" OF THE FILE 



            #        open(CHANGE,">$name") || die "no open on $name: $!";                          
            #        while(<CHANGE>)        {
            #                                s/www\.fire/samson\.fire/g;
            #                               }
            #        close(CHANGE)         || die "no close on $name: $!";



  #   THEN I TRIED TO DO IT IN A LIST CONTEXT AND WITH A MATCHING OPERATOR
  #   SAME RESULT: 0 BYTE. I DEFINITELY THINK IT'S THE "OPEN" NOW.
 


              #       foreach $line (open(CHANGE,">$name")) {
              #               $line=~s/www\.fire/samson\.fire/g
              #                                             }
              #        close(CHANGE)     



  #  MY CURRENT WORKAROUND IS USING A SHELLSCRIPT THAT TRAVERSES A FILE TREE
  #  AND PERFORMS A "perl -n -i -e 's/old/new/ig' " ON EACH FILE IN A KSHELL
  #  FOR-LOOP. THIS IS VERY CONSUMING AND, WORSE, VERY BAD STYLE


  # SO IF ANYBODY HAS AN IDEA WHAT TO PUT BETWEEN THE "HERE" ABOVE (RIGHT
  # AFTER THE FILE TEST) ____PLEASE____ LET ME KNOW. I HAVE TO GET THIS ONE
  # UP AND RUNNING.

  #  THANK YOU IN ADVANCE





--------------x------------------------------------------------------------


  -------------------------------------------------------------------------
  message by    Dr. Hans-Christian Waldmann, Dipl.Psych.

        |       Center for Rehabilitation Research at University of Bremen
        |       Grazer Strasse 2b                   28359 Bremen / Germany
        |       Tel. (+49)-(0)421-218-4715      Fax: (+49)-(0)421-218-4617

        |       home          :   thinklab@alf.zfn.uni-bremen.de
        |       office        :   waldmann@samson.fire.uni-bremen.de
  
  homepage (AIX/SAS/STATS/)       http://samson.fire.uni-bremen.de/waldmann
  -------------------------------------------------------------------------




  -------------------------------------------------------------------------
    message by        Dr. Hans-Christian Waldmann, Dipl.Psych.

        |       Center for Rehabilitation Research at University of Bremen
        |       Grazer Strasse 6                    28359 Bremen / Germany
        |       Tel. (+49)-(0)421-218-4715      Fax: (+49)-(0)421-218-4617

    Private mail 1           :  thinklab@alf.zfn.uni-bremen.de
    Private mail 2           :  thinklab@rummelplatz.uni-mannheim.de    
    nine_to_five_at_office   :  waldmann@tiffy.fire.uni-bremen.de
    Statistical consulting   :  methoden@tiffy.fire.uni-bremen.de

    homepage (SAS / SPSS / TEX / AIX / STATS ON THE NET / HEALTH SCIENCES)             
 
                                http://alf.zfn.uni-bremen.de/~thinklab
  -------------------------------------------------------------------------



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

Date: Wed, 23 Sep 1998 13:29:26 +0100
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: in-place-edit regex substitution in multiple files
Message-Id: <3608E9A6.7EC4A598@qmw.ac.uk>

>  #   THIS FRAGMENT FITS "HERE" BUT FILE HAS 0 BYTE AFTER THE "CHANGE". MAYBE
>  #   THERES SOMETHING WRONG WITH THE WAY I PERFORM THE "OPEN" OF THE FILE
> 
>             #        open(CHANGE,">$name") || die "no open on $name: $!";
>             #        while(<CHANGE>)        {
>             #                                s/www\.fire/samson\.fire/g;
>             #                               }
>             #        close(CHANGE)         || die "no close on $name: $!";

Firstly, you have only modified the string in MEMORY, not in the file.

Secondly, open (CHANGE, ">$name") creates a new file, and erases any
existing contents.  There are two simple ways to deal with this:

(1) Begin by renaming the file to some temporary name (say $name.bak)
using rename, then reading from $name.bak (with open(FROM,"<$name.bak"))
and writing to $name (with open(TO,">$name")):

   while (<FROM>) {
      s/www\.fire/samson.fire/g;
      print TO $_;
   }

(2) Read the whole file into a variable first:

   undef $/;
   open(CHANGE,"+<$name") || die "...";
   $file = <CHANGE>;
   $file =~ s/www\.fire/samson.fire/g;
   print CHANGE $file;

I haven't tested the second one though.

HTH,

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


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

Date: Wed, 23 Sep 1998 12:56:51 GMT
From: mt@dev.null (Mads Toftum)
Subject: Re: in-place-edit regex substitution in multiple files
Message-Id: <3608ec8e.6967196@news.inet.tele.dk>

On 23 Sep 1998 11:59:34 GMT, waldmann@tiffy.fire.uni-bremen.de (Dr.
H.-Christian Waldmann) wrote:

>CALL A "NEWBIE". ANYWAY, PLEASE DON'T DIRECT ME TO THE DOCS BECAUSE I HAVE

And a newbie to usenet also... writing in upper case is compared to
shouting and is considered rude.

> #   THIS FRAGMENT FITS "HERE" BUT FILE HAS 0 BYTE AFTER THE "CHANGE". MAYBE
> #   THERES SOMETHING WRONG WITH THE WAY I PERFORM THE "OPEN" OF THE FILE 
>
>
>
>            #        open(CHANGE,">$name") || die "no open on $name: $!";                          
>            #        while(<CHANGE>)        {
>            #                                s/www\.fire/samson\.fire/g;
>            #                               }
>            #        close(CHANGE)         || die "no close on $name: $!";

I still think that you should read: perldoc -f open
There you would see that your use of the > in open means open the file
for write only access. So you never get to read the original content
of the file $name.

>              #       foreach $line (open(CHANGE,">$name")) {
>              #               $line=~s/www\.fire/samson\.fire/g
>              #                                             }
>              #        close(CHANGE)     
>
Same mistake here.

>
>
>  #  MY CURRENT WORKAROUND IS USING A SHELLSCRIPT THAT TRAVERSES A FILE TREE
>  #  AND PERFORMS A "perl -n -i -e 's/old/new/ig' " ON EACH FILE IN A KSHELL
>  #  FOR-LOOP. THIS IS VERY CONSUMING AND, WORSE, VERY BAD STYLE

well you could use:
find . -name '*.txt' -exec perl -ni -e 's/old/new/ig' {} \;



vh.

Mads Toftum, (QDPH/JAPH)
---
A computer lets you make more mistakes faster than any other 
invention, with the possible exceptions of handguns and Tequilla.
        -- Mitch Ratcliffe


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

Date: Wed, 23 Sep 1998 08:26:39 -0400
From: John Porter <jdporter@min.net>
Subject: Re: MLDBM object methods
Message-Id: <3608E8FF.DA2CCEE1@min.net>

Steve Manes wrote:
> 
> Can someone tell me how to access the FIRSTKEY, NEXTKEY, etc. DBM
> object methods in MLDBM (using GDBM)?  I see them in the MLDBM.pm
> module but I can't fnd any docs to explain how to get at them.
> 
> Also, LASTKEY and PREVKEY methods appear to be missing.

I hope you're "tie"ing to MLDBM, right?
(perldoc MLDBM)
(perldoc -f tie)

If you're doing that, you shouldn't need to call those methods
directly.  However, if you really know what you're doing, you
can call those methods like so:

  $dbm = tie %o, 'MLDBM', ...;
  $key = tied($dbm)->FIRSTKEY;

(perldoc -f tied)

-- 
John "Many Jars" Porter


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

Date: 23 Sep 1998 09:57:59 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906544584.493135@thrush.omix.com>

George Reese <borg@imaginary.com> wrote:
: In comp.lang.java.programmer Zenin <zenin@bawdycaste.org> wrote:
	>snip<
: If you want to claim I am saying things that I say I did not say, THEN
: PROVE IT.  Post the quotes here.

	I'm sorry if I feel that posting entire news articles verbatim
	is pointless.  You however, have made it quite clear that anything
	short of that would be to quote you "out of context"...

	>snip<
: No, you have tried to characterize me as such.  You don't have the
: first bit of evidence to back up that characterization.

	I have nearly 200 articles in this thread alone to back that up.

	>snip<
: : 	Your own assertions do not equal "support".
: In fact, they do.  You can argue with those assertions.  But a
: supported argument is one in which the premises lead to the
: conclusion.  I have provided premises that do lead to my conclusion.

	With "logic" that is illogical, therefor the "conclusions" are
	invalid until such time that you can apply correct logic to your
	arguments.

: You can argue the premises, 

	I can argue the logic, or lack thereof.

	>snip<
: : 	So basically, if one is using language Foo and comes to a problem
: : 	that is best solved with the paradigm of language Bar, that it is
: : 	best to create a workaround kluge using only Foo's paradigm?
:
: This is a silly question because you should determine your language
: based on the requirements of your system.  So if your problem requires
: paradigm A, you use a language that supports paradigm A.  If it
: instead requires paradigm B, you use a language that supports paradigm
: B. 
:
: How hard is this principle for you to understand?

	So, basically you are completely ignoring any and all possibility
	that an application might be large and complex enough that different
	parts of it may require different paradigms.  Or are you saying that
	such systems should be built in a dozen different languages to
	correctly match the dozen different paradigms that may be required?

	This is a completely false notion.  In fact, the more complex a
	given problem the *greater* the likelihood that multiple paradigms
	will be required.

	How hard is this principle for you to understand?

: : 	What if Java had closures.  Would it be "wrong" to actually use them?
: : 	Or would Java some how be less of a language for even supporting
: : 	such a paradigm?
:
: Java has method pointers.  A similar concept that does work in an OO
: paradigm.

	Java has no method pointers, only interfaces and inner classes.
	Neither are not the same as closures, although they can be used
	as kluges for similar effects albeit with less power and "freedom".

: : 	Which, without sighting evidence you still have failed to
: : 	provide, is dogma.
:
: If that was the only statement I had ever made in this thread, you
: would be correct.  However, I have said a lot more than that.

	Oh yes, you have.  99% of it to the same conclusion.

	>snip<
: : 	Oh, you've been quite explicit.  There is no need to read anything
: : 	into your statements as you've made yourself quite clear.
:
: Then please quote them.

	I will not repost entire articles that are commonly available
	on DejaNews, and pulling out the interesting quotes even with
	message ID references simply will result in more, "that's out
	of context" whining.

	>snip<
: You are a master of taking something someone says and then extending
: it beyond their words into an extremist state.

	And you sir, are a master at semantic games.

: I said that OO's weakness lies in performance of speed critical
: systems.  That implies that I think an OO programming approach is bad
: for such systems.  That does not imply those are the only systems for
: which such an approach is bad. 

	Ok, lets cut to the chase.  Please tell us, *exactly* the list
	of system types or whatever for which you think OO is bad.  If
	you don't want people to "extent your words into an extremist
	state", then stop playing these childish semantic games and
	be *explicit* in the extreme.

: There are a lot of such systems.

	Then *name them*, *EXPLICITLY*, and stop playing games.

: By the way, how many exceptions do I have to give you before you stop
: assigning me the extremist position?

	When you stop contradicting yourself, I'll think about it.

: Or better yet, would you like to provide an example of an application
: for which OO is not appropriate on technical merits not related to
: performance?

	Most application servers.  Actually, they are commonly best
	handled in a mix of OO and procedural code.  Mainly a procedural
	socket handling, access control, and request brokering outer
	loop over OO request handlers.

	Statistic parsers, for similar reasons above.

	Databases, even "OO databases", for similar reasons above.

	etc...

	This is not a performance issue, it is simply the fact that the
	main core of the application simply goes from point A to point
	B, dispatches as yet unknown point C, then returns to finish up
	with point D, always.  A very, very common system that gains nothing
	by sticking the main control loop inside a method of an object
	that will never call anything else.  To do so would be to program
	in a procedural fashion within an OO framework, as well as simply
	be silly in many cases.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Wed, 23 Sep 1998 08:17:54 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Perl Database library?
Message-Id: <3608E6F2.287A388D@min.net>

Neil,
I don't know if you ever received an answer to this post;
but in case you haven't...

Did you check the CPAN for modules that do more or less
what you want?  Start by looking at 
	http://www.perl.com/CPAN-local/CPAN.html
particularly section 7 (Database Interfaces).
Also have a look at
	http://www.perl.com/CPAN/modules/00modlist.long.html
which has a more comprehensive list of modules.

If you have any questions about what you see there, or
would like more advice about how to proceed, feel free
to email me.

John Porter


Neil McIver wrote:
> 
> I've been doing Perl for about 3 years now and have decided
> that it would be really neat if perl had a stronger database
> ability beyond the quick & dirty DBM data system.  Something
> that could handle large numbers of multiple records without
> swelling into a 500k file (which I've noticed DBM's can do
> with a few large fields).
> 
> I looked briefly a few months ago but didn't find anything
> like that so I started writing my own, modeling it after the
> "dbase" database format.  I'm off to a good start, but just
> to make sure I'm not re-inventing the wheel, does anyone know
> if there's already something in existance like this?  Basically
> I'm thinking of a library of perl functions for creating &
> maintaining moderate amounts of data (thousands of records
> & hundreds of fields) in a reasonably efficient file, with
> indexing.  I'll feel a little stupid if there is, but please
> don't spare me.
> 
> If there isn't and anyone's interested I'll be happy to
> shareware what I've got so far.
> 
> Cheers,
> 
> Neil


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

Date: Wed, 23 Sep 1998 09:50:39 +0200
From: joris jansen <jansen@ats.nld.alcatel.nl>
To: Ralph SOBEK <sobek@irit.fr>
Subject: Re: Perl5.005_02 build: "Thread.xs", line 465: undefined symbol: YIELD
Message-Id: <3608A84F.25354FE6@ats.nld.alcatel.nl>

Ralph SOBEK wrote:
> 
> "Thread.xs", line 465: undefined symbol: YIELD
> "Thread.c", line 811: cannot recover from previous errors
> 
> Can someone tell me what went wrong?
> 
> Thanks to all!


Did you receive any usefull reactions on this message ??
I have the same problem, that's why I'd like to know ...

I have an idee but don't know it for sure:
I'm almost sure there's some patch from Sun concerning multi-threading
and Solaris 2.5.x. I guess you can't use multi-threading in Perl without
this patch to the OS. Does make sense, doesn't it ??

	Joris


-- 
+----------------------------------+-----------------------------------+
| Joris Jansen                     | Alcatel Telecom Nederland         |
| jansen@ats.nld.alcatel.nl        | Postbus 3292                      |
| phone +31 (70) 307 9136          | 2280 GG  Rijswijk (ZH)            |
| fax   +31 (70) 307 9191          | The Netherlands                   |
+----------------------------------+-----------------------------------+
| No question is too silly to ask, though some are too silly to answer |
+----------------------------------------------------------------------+


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

Date: Wed, 23 Sep 1998 13:22:47 +0100
From: "Guillaume Buat-Menard" <guillaume@nospam.com>
Subject: problem retreiving cookie
Message-Id: <6uapas$3qk$1@newsreader1.core.theplanet.net>

Hi all,

I have a perl script on my NT server that works fine, setting a cookie and
retreiving the value with another script.

When I installed these two scripts on another server (Unix) and made all the
according changes (domain name...) the first script setting the cookie works
and I checked the cookie was set. The retrieving script does read the cookie
string but this string is empty ($ENV{HTTP_COOKIE}).

My question is: is it possible that the configuration on the new server
doesn't allow to read the cookie string or not?

If not have you got any Idea why my cookie string is empty?

thanks for your help,

Guillaume.




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

Date: Wed, 23 Sep 1998 06:59:40 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <crnau6.vr.ln@flash.net>

Andrea Spinelli (aspinelli@ismes.it) wrote:

[snip]

: However, @a may be empty; in this case, I want to pick an element from
: keys %h,
: (any element will do) and put it into @a. My current solution is:

: if( $#a < 0 ){
:     my ($k,$v) = each %h;
:     @a = ($k);
: }

: Is there any better/more elegant/more efficient way of picking an
: arbitrary
: element from a hash?  


   push @a, (keys %h)[0] if @a == 0; 


   I am not familar with Zorn's lemma.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 23 Sep 1998 08:42:15 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <3608ECA7.2E7058FF@min.net>

Andrea Spinelli wrote:
> 
> if ( $#a < 0 ) {
>     my ($k,$v) = each %h;
>     @a = ($k);
> }

This is an excellent way of doing it -- as long as you 
truly don't care how the element is chosen.  
If you actually need randomness, then you could do 
something with keys() and rand().

-- 
John "Many Jars" Porter


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

Date: Wed, 23 Sep 1998 09:01:37 -0400
From: changling@erols.com
Subject: Sockets question
Message-Id: <MPG.1072bb3b8253b202989682@news.erols.com>

The PerlShop shopping cart contains the following subroutine for sending 
an email:

sub sockets_mail
{
    my ($to, $from, $subject, $message) = @_;

    my ($replyaddr) = $from;
   
    if (!$to) { return -8; }

    my ($proto, $port, $smptaddr);

    my ($AF_INET)     =  2;
    my ($SOCK_STREAM) =  1;

    $proto = (getprotobyname('tcp'))[2];
    $port  = 25;

    $smtpaddr = ($smtp_addr =~ 
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
                    ? pack('C4',$1,$2,$3,$4)
                    : (gethostbyname($smtp_addr))[4];

    if (!defined($smtpaddr)) 	{	return -1;	}

    if (!socket(S, $AF_INET, $SOCK_STREAM, $proto))	{ return -2; }
    if (!connect(S, pack('Sna4x8', $AF_INET, $port, $smtpaddr))) 
	{return -3; }  

    my($oldfh) = select(S); $| = 1; select($oldfh);

    $_ = <S>; if (/^[45]/) { close S; return -4; }

    print S "helo localhost\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }

    print S "mail from: $from\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }
   
    print S "rcpt to: $to\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -6; }
    

    print S "data\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }

    print S "X-Mailer: PerlShop Sendmail \r\n";
    print S "Mime-Version: 1.0\r\n";
    print S "Content-Type: text/plain; charset=us-ascii\r\n";
    print S "To: $to\r\n";
    print S "From: $from\r\n";
    print S "Reply-to: $replyaddr\r\n" if $replyaddr;
    print S "Subject: $subject\r\n\r\n";
    print S "$message";
    print S "\r\n.\r\n";

    $_ = <S>; if (/^[45]/) { close S; return -7; }

    print S "quit\r\n";
    $_ = <S>;

    close S;
    return 1;
}

Everytime this subroutine is called, it fails returning -3.  Anyone have 
any idea why?



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

Date: 23 Sep 1998 12:02:17 +0200
From: Thomas Neumann <tom@smart.ruhr.de>
Subject: Re: sorting Unix pathnames of unequal length by filename
Message-Id: <873e9jrvti.fsf@smart.ruhr.de>

lynn_newton@mcg.mot.com (Lynn D. Newton) writes:

> Has anyone written any code to sort a list of Unix
> pathnames by the final name in the path, regardless of
> the number of segments in the path, and using the rest
> of the path, from the beginning, as a secondary sort
> key? This could be useful in finding duplicate
> filenames in different trees. For instance:
> 
> /b/c/d/e/f/g/abc.c
> /a/b/c/abc.c
> /c/aab.c
> 
> would be sorted as
> 
> /c/aab.c
> /a/b/c/abc.c
> /b/c/d/e/f/g/abc.c



#!/usr/bin/perl -wT

use strict;
use File::Basename;

sub sort_by_basename(@);

sub sort_by_basename(@) {
	map { $_->[0] }
	sort { $a->[2] cmp $b->[2] or $a->[1] cmp $b->[1] }
	map { [$_, dirname($_), basename($_)] }
	@_;
}

for (sort_by_basename(<DATA>)) { print $_ }

__DATA__
/b/c/d/e/f/g/abc.c
/a/b/c/abc.c
/c/aab.c


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

Date: Wed, 23 Sep 1998 08:37:02 -0400
From: John Porter <jdporter@min.net>
Subject: Re: speed of subroutine call vs. call by function reference
Message-Id: <3608EB6E.7CD32700@min.net>

Dan Sugalski wrote:
> 
> Lexical @_ seems to add some overhead too.

"Lexical @_" ???

Either I am badly confused, or this term is lacking in precision.
Can you clarify?

-- 
John "Many Jars" Porter


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

Date: Wed, 23 Sep 1998 12:09:00 +0400
From: Andrew Yourtchenko <andin@webclub.ru>
To: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: User authorization; WAS: Hidden field???
Message-Id: <3608AC9C.D8E0ECDF@webclub.ru>

Howdy,

I also faced this problem, but since we use Apache here, it was solved rather easily
- by writing a proper .htacccess file and a plain-text apache password database
access library in Perl. I tried to implement file locking for multiaccess purposes
and some caching for performance reasons etc. So that the users can be added/deleted
on the fly.

If it is of any use to you, you can fetch it from
http://www.webclub.ru/repository/archive/cgi-scripts/passwd.zip

Eric Von Zee wrote:

> Howdy,
>
> I've come up against this problem myself, and I've thought of the following
> solutions:
>
> 1) Write the user's IP address to a file (or make a file called "$userip.ip")
> Have the program create/write this file when a valid password is entered, and
> delete it after timelimit or on logout button
>
> 2) Use a cookie.  There are Perl cookie write/check/unwrite routines out there (I
> just forget where..)
>
> 3) Go ahead and make a hidden variable and use it with Pragma:no-cache and #1
> above (probably most secure of the 3)
>
> If anyone out there has better ideas, I myself would be glad to hear them.
>
> HTH!
>
> Cheers,
>
> Eric
>
> ywang@maingate.net wrote:

[ the rest was skipped not to overload the net ]

---
wbr,
andin

http://www.webclub.ru/ - All-Russia webmasters' club.




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3795
**************************************

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