[10201] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3794 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 23 04:07:10 1998

Date: Wed, 23 Sep 98 01:00:19 -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: 3794

Today's topics:
    Re: cat reese > /dev/null (was Re: Perl & Java - differ <borg@imaginary.com>
    Re: Cookie Help! Kresimir.Puskaric@siemens.at
    Re: Perl & Java - differences and uses (David Adler)
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses <ajohnson@gpu.srv.ualberta.ca>
    Re: Perl & Java - differences and uses (David Formosa)
        Q: Picking an element from a hash (not knowing which!)  <aspinelli@ismes.it>
        Sending Filename For Browser <juha@crec08.bus.utexas.edu>
    Re: Sending Filename For Browser <andin@webclub.ru>
    Re: Simple, efficient way of checking whether $VAR is a (Steffen Beyer)
    Re: sorting Unix pathnames of unequal length by filenam (David A. Black)
        Statically linking decrypt.pl in NT? <standfast@mindspring.com>
    Re: unlink() not working in NT!!?? <standfast@mindspring.com>
    Re: where is Date::Parse (CPAN.pm)? (Steffen Beyer)
        Where is perl debugger GUI (tkperl)?? (Jete Software Inc.)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 23 Sep 1998 06:09:13 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <dg0O1.1520$Ge.4809664@ptah.visi.com>

In comp.lang.java.programmer David Formosa <dformosa@zeta.org.au> wrote:
: In <VkRN1.1403$Ge.4351102@ptah.visi.com> George Reese <borg@imaginary.com> writes:

:>In comp.lang.java.programmer Uri Guttman <uri@camel.fastserv.com> wrote:
:>: tho it is nice to hear that someone has seen his OO code and it is as
:>: logical as he is.

:>Abigail is blowing smoke.  At no time has Abigail seen anything
:>representative of my work.

: It is possable that Abigail has seen some of your work, possably when 
: thay where doing matence on your system built by you.

Abigail saw some code from a game I worked on 10 years ago when I was
first learning to code.  As I stated in another post, who all here
wants to be judged by the first piece of code they wrote?

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Wed, 23 Sep 1998 06:11:44 GMT
From: Kresimir.Puskaric@siemens.at
Subject: Re: Cookie Help!
Message-Id: <1103_906531104@TK32142KP>

Hello Brian,

> Can anyone direct me to (hopefully) an on-line or downloadable file that
> explains how to use cookies; ie. writing, reading, etc.
> 
> Brian Enderle
> 

Perhaps the following script could help you:
---------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl

##############################################################################
# HTTP Cookie Library           Version 2.1                                  #
# Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
# Created 07/14/96              Last Modified 12/23/96                       #
# Script Archive at:            http://www.worldwidemart.com/scripts/        #
#                               Extensive Documentation found in README file.#
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1996 Matthew M. Wright.  All Rights Reserved.                    #
#                                                                            #
# HTTP Cookie Library may be used and modified free of charge by anyone so   #
# long as this copyright notice and the comments above remain intact.  By    #
# using this code you agree to indemnify Matthew M. Wright from any          #
# liability that might arise from it's use.                                  #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.  In all cases copyright and header must remain intact.#
##############################################################################
# Define variables for this library.                                         #

    # This is an optional variable.  If not defined, the cookie will expire  #
    # when a user's session ends.                                            #
    # Should be defined as: Wdy, DD-Mon-YYYY HH:MM:SS GMT                    #

$Cookie_Exp_Date = '' ;

    # By default this will be set to the same path as the document being     #
    # described by the header which contains the cookie.                     #

$Cookie_Path = '' ;

    # By default this will be set to the domain host name of the server      #
    # which generated the cookie response.                                   #

$Cookie_Domain = '' ;

    # This should be set to 0 if the cookie is safe to send across over      #
    # unsecured channels.  If set to 1 the cookie will only be transferred   #
    # if the communications channel with the host is a secure one. Currently #
    # this means that secure cookies will only be sent to HTTPS (HTTP over   #
    # SSL) servers.  According to Netscape docs at least.                    #

$Secure_Cookie = '0' ;

    # These are the characters which the HTTP Cookie Library will translate  #
    # to url encoded (hex characters) when it sets individual or compressed  #
    # cookies.  The array holds the order in which these should be           #
    # translated (as we wouldn't want to translate spaces into pluses and    #
    # then pluses into the URL encoded form, but rather the other way        #
    # around) and the associative array holds the values to translate        #
    # characters into.  The decoded set will reverse the process.  Feel free #
    # to add any other characters here, but it shouldn't be necessary.       #
    # This is a correction in version 2.1 which makes this library adhere    #
    # more to the Netscape specifications.                                   #

@Cookie_Encode_Char = ( '\%' , '\+' , '\;' , '\,' , '\=' , '\&' , '\:\:' , '\s' ) ;

%Cookie_Encode_Chars = ( '\%' , '%25' , '\+' , '%2B' , '\;' , '%3B' , '\,' , '%2C' , '\=' , '%3D' , '\&' , '%26' , '\:\:' , '%3A%3A' , '\s' , '+' ) ;

@Cookie_Decode_Char = ( '\+' , '\%3A\%3A' , '\%26' , '\%3D' , '\%2C' , '\%3B' , '\%2B' , '\%25' ) ;

%Cookie_Decode_Chars = ( '\+' , ' ' , '\%3A\%3A' , '::' , '\%26' , '&' , '\%3D' , '=' , '\%2C' , ',' , '\%3B' , ';' , '\%2B' , '+' , '\%25' , '%' ) ;
# Done                                                                       #
##############################################################################

##############################################################################
# Subroutine:    &GetCookies()                                               #
# Description:   This subroutine can be called with or without arguments. If #
#                arguments are specified, only cookies with names matching   #
#                those specified will be set in %Cookies.  Otherwise, all    #
#                cookies sent to this script will be set in %Cookies.        #
# Usage:         &GetCookies([cookie_names])                                 #
# Variables:     cookie_names - These are optional (depicted with []) and    #
#                               specify the names of cookies you wish to set.#
#                               Can also be called with an array of names.   #
#                               Ex. 'name1','name2'                          #
# Returns:       1 - If successful and at least one cookie is retrieved.     #
#                0 - If no cookies are retrieved.                            #
##############################################################################

sub GetCookies {

    # Localize the variables and read in the cookies they wish to have       #
    # returned.                                                              #

    local ( @ReturnCookies ) = @_ ;
    local ( $cookie_flag ) = 0 ;
    local ( $cookie,$value ) ;

    # If the HTTP_COOKIE environment variable has been set by the call to    #
    # this script, meaning the browser sent some cookies to us, continue.    #

    if ( $ENV{'HTTP_COOKIE'} ) {

        # If specific cookies have have been requested, meaning the          #
        # @ReturnCookies array is not empty, proceed.                        #

        if ( $ReturnCookies[0] ne '' ) {

            # For each cookie sent to us:                                    #

            foreach ( split( /; / , $ENV{'HTTP_COOKIE'} ) ) {

                # Split the cookie name and value pairs, separated by '='.   #

                ( $cookie , $value ) = split( /=/ ) ;

                # Decode any URL encoding which was done when the compressed #
                # cookie was set.                                            #

                foreach $char ( @Cookie_Decode_Char ) {
                    $cookie =~ s/$char/$Cookie_Decode_Chars{$char}/g ;
                    $value =~ s/$char/$Cookie_Decode_Chars{$char}/g ;
                }

                # For each cookie to be returned in the @ReturnCookies array:#

                foreach $ReturnCookie ( @ReturnCookies ) {

                    # If the $ReturnCookie is equal to the current cookie we #
                    # are analyzing, set the cookie name in the %Cookies     #
                    # associative array equal to the cookie value and set    #
                    # the cookie flag to a true value.                       #

                    if ( $ReturnCookie eq $cookie ) {
                        $Cookies{$cookie} = $value ;
                        $cookie_flag = "1" ;
                    }
                }
            }

        }

        # Otherwise, if no specific cookies have been requested, obtain all  #
        # cookied and place them in the %Cookies associative array.          #

        else {

            # For each cookie that was sent to us by the browser, split the  #
            # cookie name and value pairs and set the cookie name key in the #
            # associative array %Cookies equal to the value of that cookie.  #
            # Also set the coxokie flag to 1, since we set some cookies.      #

            foreach ( split( /; / , $ENV{'HTTP_COOKIE'} ) ) {
                ( $cookie , $value ) = split( /=/ ) ;

                # Decode any URL encoding which was done when the compressed #
                # cookie was set.                                            #

                foreach $char ( @Cookie_Decode_Char ) {
                    $cookie =~ s/$char/$Cookie_Decode_Chars{$char}/g ;
                    $value =~ s/$char/$Cookie_Decode_Chars{$char}/g ;
                }

                $Cookies{$cookie} = $value ;
            }
            $cookie_flag = 1 ;
        }
    }

    # Return the value of the $cookie_flag, true or false, to indicate       #
    # whether we succeded in reading in a cookie value or not.               #

    return $cookie_flag ;
}

##############################################################################
# Subroutine:    &SetCookies()                                               #
# Description:   Sets one or more cookies by printing out the Set-Cookie     #
#                HTTP header to the browser, based on cookie information     #
#                passed to subroutine.                                       #
# Usage:         &SetCookies(name1,value1,...namen,valuen)                   #
# Variables:     name  - Name of the cookie to be set.                       #
#                        Ex. 'count'                                         #
#                value - Value of the cookie to be set.                      #
#                        Ex. '3'                                             #
#                n     - This is tacked on to the last of the name and value #
#                        pairs in the usage instructions just to show you    #
#                        you can have as many name/value pairs as you wish.  #
#               ** You can specify as many name/value pairs as you wish, and #
#                  &SetCookies will set them all.  Just string them out, one #
#                  after the other.  You must also have already printed out  #
#                  the Content-type header, with only one new line following #
#                  it so that the header has not been ended.  Then after the #
#                  &SetCookies call, you can print the final new line.       #
# Returns:       Nothing.                                                    #
##############################################################################

sub SetCookies {

    # Localize variables and read in cookies to be set.                      #

    local ( @cookies ) = @_ ;
    local ( $cookie , $value , $char ) ;

    # While there is a cookie and a value to be set in @cookies, that hasn't #
    # yet been set, proceed with the loop.                                   #

    while( ( $cookie , $value ) = @cookies ) {

        # We must translate characters which are not allowed in cookies.     #

        foreach $char ( @Cookie_Encode_Char ) {
            $cookie =~ s/$char/$Cookie_Encode_Chars{$char}/g ;
            $value =~ s/$char/$Cookie_Encode_Chars{$char}/g ;
        }

        # Begin the printing of the Set-Cookie header with the cookie name   #
        # and value, followed by semi-colon.                                 #

        print 'Set-Cookie: ' , $cookie , '=' , $value , ';' ;

        # If there is an Expiration Date set, add it to the header.          #

        if ( $Cookie_Exp_Date ) {
            print ' expires=' , $Cookie_Exp_Date , ';' ;
        }

        # If there is a path set, add it to the header.                      #

        if ( $Cookie_Path ) {
            print ' path=' , $Cookie_Path , ';' ;
        }

        # If a domain has been set, add it to the header.                    #

        if ( $Cookie_Domain ) {
            print ' domain=' , $Cookie_Domain , ';' ;
        }

        # If this cookie should be sent only over secure channels, add that  #
        # to the header.                                                     #

        if ( $Secure_Cookie ) {
            print ' secure' ;
        }

        # End this line of the header, setting the cookie.                   #

        print "\n" ;

        # Remove the first two values of the @cookies array since we just    #
        # used them.                                                         #

        shift( @cookies ) ;
        shift( @cookies ) ;
    }
}

# This statement must be left in so that when perl requires this script as a #
# library it will do so without errors.  This tells perl it has successfully #
# required the library.                                                      #

1 ;


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

Date: 23 Sep 1998 06:10:00 GMT
From: dha@panix.com (David Adler)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6ua3bo$doi@news1.panix.com>

On Tue, 22 Sep 1998 22:43:09 GMT, Elaine -HappyFunBall- Ashton
<eashton@bbnplanet.com> wrote:

>Personally, I think aliens built The Pyramids, Luxor, Stonehenge and The
>Mayan temples. ;)

Wow!  I knew Randal was a bit odd, but an alien?  Will wonders never
cease?

:-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"What is this Japanese preoccupation with the name Ken???" - Tom Servo


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

Date: Wed, 23 Sep 1998 06:25:32 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <wv0O1.1521$Ge.4809664@ptah.visi.com>

In comp.lang.java.programmer Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> wrote:
: George Reese wrote:
: !
: [snip]
: George Reese wrote:
: !
: [snip]
: ! I have provided premises which you can debate or not.  You have not
: ! chosen to debate those premises.  What exactly do you want?
: !
: ! If I say:
: !
: ! All Americans speak French.
: ! I am American.
: ! Therefore I speak French.
: !
: ! As this argument follows from the premises, I have provided an
: ! argument with support.  You can either choose to debate my premises or
: ! concede that I speak French.

: that is not an argument following from premises, it is a logical
: conclusion, and while taken all together it is internally
: consistent that does not make it a 'supported' argument --- you need
: to support your premises as well.

It is an argument that follows from the premises.  

You are bordering on ridiculous if you think you need to support your
premises.  Such an argument is an infinite regression.  A proper
argument states premises and a conclusion.  Then others may disagree
with the validity of the argument (it does not follow from the
premises) or they disagree with a specific premise.  At that point we
can delve into problems with a specific premise if there are any.

: ! I think the premises I have offered in this past support this
: ! statement.  If you disagree, please address the problematic premise.

: I have done so ... I will do so once again, since you still do
: not see the problem:

: Here are your original premises, followed with word substitutions for
: terms you later clarified:

: (1)
: ! * In order to get quality software, you need a method of guaranteeing
: !   results given a problem.

: you later said change 'get' to 'guarantee' and that the 'results'
: being discussed was the 'production of software':

:     In order to "guarantee" quality software, you need a method of
:     guaranteeing "the production of software" given a
:     problem.

: (2)
: ! * If you want to guarantee results, you need to be able to reduce a
: !   process to a replicatable algorithm.

: now again, 'results' is the 'production of software', so
: premise two is:

:     If you want to guarantee "the production of software", you
:     need to be able to reduce a process to a replicable algorithm

: now, you never mentioned what the 'process' was --- but I think we can
: infer that you meant something like: "you need to be able to reduce
: the process of producing software to an algorithm"
: (feel free to correct me if my inferences are incorrect)

: (3)
: ! * OO is the closest thing to a replicatable algorithm we have in
: !   software engineering today.

: (this is the 'skyhook', for Dennet fans)

What is a skyhook about this?  I am saying that of all approaches to
building software, OO software engineering is closer than any other to
being reproduceable.  There is no magic here.

: 4)
: ! * OO does sometimes incur performance costs and thus the predticability
: !   of the process is sometimes offset by these performance costs.

: (5)
: ! * Most software engineering tasks do not encounter a requirement for
: !   the the level of performance cost by OO software engineering.

: (these last two are not really germane to main problem with the logic)

: (conclusion)
: ! - Therefore, it is the best solution for any software engineering task
: !   where the side effects

: you corrected this to read:

:     Therefore, it is the best solution for most software engineering
:     tasks.

: ---------

: summary: if you want to guarantee the production of quality software,
: you need a method which guarantees the production of software, and
: furthermore, to be such a guarantor, such a method must be reducible
: to an algorithm --- OO is the nearest thing we have to being an
: algorithm for software production, therefore, it is the best
: solution for most software production.

: George, leaving aside questions about whether there is any support for
: any of your premises, you've unwittingly made an unsound leap between
: premise 2 and 3 --- premise 2 poses a 'necessary condition' ... that
: the process or 'method of software production' must be reducible to
: an algorithm in order to guarantee results. This is obviously Not a
: 'sufficient condition' for guaranteeing the *quality* results... if
: someone poses an algorithm that guarantees "the production of
: software", that does not mean it also guarantees "the production of
: *quality* software" does it?

No, but that is not important to my argument.  Reproducibility is
neither a necessary nor sufficient condition for quality software.
Clearly someone hacking away in their basement more or less at random
is capable of producing quality software and clearly I can come up
with true honest-to-god algorithms for building crap software.

For predictability, however, repeatability is necessary.
Specifically, in order to be able to say with any demonstrable
certainty (i.e. certainty that a third party like a client will
accept), I have to show a process whose results can reasonably be
predicted.  And, as I stated above, repeatability is a necessary
condition for predictability.

: Therefore, even if you had shown that OO does have the property of
: algorithmic reduction (you didn't), 

I didn't even suggest it.  I said it was the closest thing.

: it couldn't guarantee *quality*
: software unless OO  already had the property of guaranteeing
: *quality* software 

OK, guarantee is probably a strong word.  Predict reliably is probably
a better phrase.

: --- the property of algorithmic reduction only
: guarantees consistent results, the quality of those results is still
: dependent upon the method you've reduced. You cannot use algorithmic
: reduction as a skyhook for your beloved OO methodology, even if you
: could demonstrate such a reduction.

My argument does not rest on algorithmic reduction.  It rests on
similarity to alogorithmic processes--i.e. more like a recipe than an
alogorithm. 

: Now do you see how your conclusion does not follow from your premises?
: end of my address of the 'problematic issues'.

I can see how some of my wording is poorly chosen in places, but I
still feel the force of my argument holds.

: BTW, you have still yet to comment on my previous remarks about
: "freedom" in programming with regard to OO, namely, does an OO
: programmer have the 'freedom' to choose among various possible OO
: implementations of a solution to a problem --- or do you somehow
: still believe that 'freedom' has no place in programming, and that
: for any problem there is only one implementable and correct solution?

I do not entirely understand what you mean by the question.  Do you
mean does the programmer get to choose the methodology?  No, that is
the job of the project lead.  Do you mean does the programmer get to
choose the language?  No, that would be a function of the lead
designer.  Does the programmer get to choose whether to use MI or
delegation?  No, that is a design decision.

Somehow, I do not think any of those questions is what you mean.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Wed, 23 Sep 1998 02:12:52 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl & Java - differences and uses
Message-Id: <36089F74.510AAC74@gpu.srv.ualberta.ca>

George Reese wrote:
!
[snip]
 
! : (3)
! : ! * OO is the closest thing to a replicatable algorithm we have in
! : !   software engineering today.
! 
! : (this is the 'skyhook', for Dennet fans)
! 
! What is a skyhook about this?  I am saying that of all approaches to
! building software, OO software engineering is closer than any other to
! being reproduceable.  There is no magic here.

the skyhook is, in premise 1 you are talking about guaranteeing
*quality* software ... in premise 2 you propose a necessary condition
of the method needing to be (or be like) an algorithm so that any result
can be guaranteed --- Now you posit that OO meets (or nearly meets) the
requirement of premise 2, and you somehow think that this connects to
premise one and the production of *quality* software --- It Does Not
Follow --- Nothing after premise 1 logically connects with the
*quality* of the software being produced, merely repeatability ...and
you already admit below that repeatability alone can be means of
repeatedly producing crap.

Therefore, no premise about OO repeatability logically connects it
to being 'the best method most of the time' either. You have to 
show that it both is reproducable AND guarantees *quality*
code...you've forgotten to show that second condition.
 
! No, but that is not important to my argument.  Reproducibility is
! neither a necessary nor sufficient condition for quality software.
! Clearly someone hacking away in their basement more or less at random
! is capable of producing quality software and clearly I can come up
! with true honest-to-god algorithms for building crap software.
! 
! For predictability, however, repeatability is necessary.
! Specifically, in order to be able to say with any demonstrable
! certainty (i.e. certainty that a third party like a client will
! accept), I have to show a process whose results can reasonably be
! predicted.  And, as I stated above, repeatability is a necessary
! condition for predictability.

yes, but showing that the process of software development is
repeatable does not show that it repeatedly produces *quality*
software --- which was the motivating condition in premise 1.
 
! 
! My argument does not rest on algorithmic reduction.  It rests on
! similarity to alogorithmic processes--i.e. more like a recipe than an
! alogorithm.

But you still seem to miss the fact the repeatability or
predictability of OO methods is irrevelant unless those methods are
already shown to be guarantors of *quality* results --- you have an
implicit circularity in your reasoning, and I think the stage at
which you miss the circularity is in premise 3 where you posit that
OO methods possess (or are the closest thing to) a certain 'valuable'
property --- but that property does not confer any *quality* status
to the results of the method...just repeatability. see above.
 
! 
! : BTW, you have still yet to comment on my previous remarks about
! : "freedom" in programming with regard to OO, namely, does an OO
! : programmer have the 'freedom' to choose among various possible OO
! : implementations of a solution to a problem --- or do you somehow
! : still believe that 'freedom' has no place in programming, and that
! : for any problem there is only one implementable and correct solution?
! 
! I do not entirely understand what you mean by the question.  Do you
! mean does the programmer get to choose the methodology?  No, that is
! the job of the project lead.  Do you mean does the programmer get to
! choose the language?  No, that would be a function of the lead
! designer.  Does the programmer get to choose whether to use MI or
! delegation?  No, that is a design decision.
! 
! Somehow, I do not think any of those questions is what you mean.

they are not: You have stated that 'freedom' has no place in
programming, so, down at the programming stage, two programmers
are given identical projects to code in an OO methodology using
the same OO language --- do they produce identical code?  do they
have any freedom in implementing the design? the classes? the methods?
If all the implementation details are worked out further up the
chain, then I would argue that the stuff going on higher in the chain
*is* programming, and any freedom they excersise is freedom in
programming (I would also argue that those on the coding floor are no
longer programmers but merely typists and transcriptionists).

regards
andrew


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

Date: 23 Sep 1998 17:24:26 +1000
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6ua7na$8sj$1@godzilla.zeta.org.au>

In <wv0O1.1521$Ge.4809664@ptah.visi.com> George Reese <borg@imaginary.com> writes:

>In comp.lang.java.programmer Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> wrote:
[...]

>: it is a logical  conclusion, and while taken all together it is internally
>: consistent that does not make it a 'supported' argument --- you need
>: to support your premises as well.

>It is an argument that follows from the premises.  

>You are bordering on ridiculous if you think you need to support your
>premises.

You have to build up your agrument from aggried facts.  You take some fact
that we both beleave to be true And use that to base your arguemtent. Other
wise its like building a carsel on a swamp.



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

Date: Wed, 23 Sep 1998 09:25:13 +0200
From: Andrea Spinelli <aspinelli@ismes.it>
Subject: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <3608A258.43F4B9C9@ismes.it>

Hi everyone,

I have a hash, which I use as the definition of a set of elements,

%h = ( foo=>1, bar=>2, baz=>3 );

>From a different program segment I obtain an array, whose elements
are picked from the keys of %h, e.g.

@a = (baz,bar);

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?  The lemma of Zorn assures that there is always a
way of picking an arbitrary element from a nonempty set; what does Perl
say
about this?

Cheers
   Andrea




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

Date: Wed, 23 Sep 1998 01:07:29 -0500
From: Juha Vehnia <juha@crec08.bus.utexas.edu>
Subject: Sending Filename For Browser
Message-Id: <36089020.288310FA@crec08.bus.utexas.edu>

Hello

I am fetching data from database and then printing content-type header
for the browser so that browser prompts user to save the file.
My problem is how to send a filename to browser, currently
filename is same as the perl script's filename.

Thanks,

mailto:juha@crec08.bus.utexas.edu

Juha Vehnia
CREC, University of Texas




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

Date: Wed, 23 Sep 1998 11:17:59 +0400
From: Andrew Yourtchenko <andin@webclub.ru>
To: Juha Vehnia <juha@crec08.bus.utexas.edu>
Subject: Re: Sending Filename For Browser
Message-Id: <3608A0A7.81A95AEA@webclub.ru>

Hi.

Though it's not exactly perl-related, but still..
The easiest way would be to add path exactly to the cgi filename, then the
browser will prompt you what you need. You can fetch the trailing path
after the cgi filename via $ENV{'PATH_INFO'}

e.g.:

fetching
http://www.webclub.ru/cgi-bin/myscript.cgi/savefile/myfile.zip

will call cgi-bin/myscript.cgi and if you feed browser with some
content-type that it would like to save, the default name for file being
saved will be myfile.zip.

I hope that helped.
---
wbr,
andin
http://www.webclub.ru/ - All-Russia webmasters' club



Juha Vehnia wrote:

> Hello
>
> I am fetching data from database and then printing content-type header
> for the browser so that browser prompts user to save the file.
> My problem is how to send a filename to browser, currently
> filename is same as the perl script's filename.
>
> Thanks,
>
> mailto:juha@crec08.bus.utexas.edu
>
> Juha Vehnia
> CREC, University of Texas





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

Date: 23 Sep 1998 06:48:48 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Simple, efficient way of checking whether $VAR is an element of set @LIST ?
Message-Id: <6ua5kg$96r$3@en1.engelschall.com>

Douglas Clifton <doug@weboneinc.com> wrote:
> Andy Armstrong wrote:
>> 
>> In article <xfkn2b4r03c.fsf@big.aa.net>, Charles Roten
>> <croten@big.aa.net> writes
>> >
>> >Yeah, it's probably a _really_ dumb question ...  but while a subroutine
>> >for such would be quite simple to write, I hate to reinvent the wheel ..
>> >and I'd bet two dollars ot a donut that this is probably already done
>> >_properly_, in some standard callable routine.
>> >
>> >I am really thinking in set-theoretic terms here.  And that's the sort
>> >of test I want.
>> >
>> >What I'm _really_ after will look like this ...
>> >
>> >@LIST = keys (%hash);
>> >if ( $VAR is an element of @LIST ) {
>> >   do stuff ;
>> >} else {
>> >   scream bloody murder .. the other shoe just dropped ;
>> >}

Why don't you use Bit::Vector for this? It's internally written in C, so
it's really fast, and it's also efficient (in terms of complexity theory).

Just assign a number to each item of interest, set the corresponding bit
in the bit vector if the item shows up, and just test its presence with
$vector->contains($number);

>> Why not just test the hash directly?
>> 
>> if ($hash{$var}) {
>>     do stuff ;
>> }

> Because the original poster was looking for a way to check for the existance
> of a variable in the set of *keys* for a hash, not the set of values. Try:

> if (grep /^$var$/, keys %hash)  {
>   do_stuff();
> }
> else  {
>   print "bloody murder, the other shoe just dropped!\n";
> }

For heaven's sake, no! :-)

   if (exists $hash{$var}) {
       do stuff ;
   }

will just do fine!

Hope this helps.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: Tue, 22 Sep 1998 16:42:59 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: sorting Unix pathnames of unequal length by filename
Message-Id: <6u924j$p3g$1@earth.superlink.net>

Hello -

Jonathan Feinberg <jdf@pobox.com> writes:

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

>Seek ye the Schwartzian Transform:

>   my @sorted = 
>     map { $_->[1] }
>     sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
>     map { my ($name) = m(([^/]+)$); [$name, $_] }  @files;


An ST with a temporary variable?!  Honestly!  :-)

my @sorted = map  { $_->[2] }
             sort { $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] }
             map  { [ m~(.*)/(.*)~,  $_ ] }
       @files;


It takes so much typing to save a little typing :-)


David Black
dblack@saturn.superlink.net


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

Date: Tue, 22 Sep 1998 23:51:36 -0700
From: "David Watson" <standfast@mindspring.com>
Subject: Statically linking decrypt.pl in NT?
Message-Id: <36089a74$0$25500@nntp1.ba.best.com>

I'm having trouble statically linking Filter::decrypt module into perl in
NT.   Before I go much further into this problem, I should do a bozo-check
on myself.  Is building perl with static linking even possible under NT?
Are there any well-known gotchas?

 Thanks,
 -David.





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

Date: Tue, 22 Sep 1998 23:42:23 -0700
From: "David Watson" <standfast@mindspring.com>
Subject: Re: unlink() not working in NT!!??
Message-Id: <3608984e$0$25510@nntp1.ba.best.com>

Thanks!

This solved the problem completely.

 -David.



>> # The open() succeeds.  The unlink() fails only on NT.
>> #
>>
>> $thefile = "C:/tmp/perltest";
>>
>> if (!open(TEST, "> $thefile")) {
>>  die($errno);
>>  }
>>
>> print("Opened OK\n");
>>
>> $result = unlink "$thefile" ;
>> printf("Result is %s\n", $result);
>
>You don't close the file. On some operating systems, and I believe
>that includes NT, file locking happens.
>
>If you know that unlink fails, you should inspect the $! variable.
>Whenever you use a system call and it fails, check $!.
>
>Martien
|




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

Date: 23 Sep 1998 06:39:00 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: where is Date::Parse (CPAN.pm)?
Message-Id: <6ua524$96r$1@en1.engelschall.com>

Russ Allbery <rra@stanford.edu> wrote:
> Steffen Beyer <sb@engelschall.com> writes:

>> There's a new Perl Resource Kit from the german section of O'Reilly
>> coming soon ("Programmieren mit Perl-Modulen" = "Programming with Perl
>> Modules") which will include a new tool called "Build'n'Play" which
>> offers that.

>> You can install Perl (including all the modules you like) and other
>> distributions (like Gimp, ImageMagick, and soon gcc and more) with it
>> using all the flexibility and computational power of Perl.

> I'll be interested to see what it looks like when it's out.  Are you using
> some sort of a standard package scheme like RPM or the like?

No, just plain Perl scripts which use a (object-oriented) Perl module for the
automatic recovery mechanism.

That way you can install whatever you like, and take whatever special
measures for special cases you have.

>> And finally, you will be able to install to a software installation
>> hierarchy which allows grouping of your installed software packages into
>> categories (subdirectories) as well as guaranteed residue-free
>> de-installation.

>> No more trampling over one another in /usr/local/bin anymore, no more
>> uncontrolled copying of files over your whole file system when doing
>> "make install".

> This is actually a solved problem for me, since we use AFS, so chances are
> high that whatever scheme some other tool uses is just going to conflict
> with the scheme that we're already using.  That's one of the reasons why I
> just started writing this myself.

This feature of "Build'n'Play" is actually optional; you can still install
to "/usr/local" (or some equivalent of your choice) of course.

And not everybody has AFS... :-)

So it might still be valuable to some people.

It has been used extensively in some middle-sized companies as well as
universities around here for several years (6) now.

>> If you want to check this tool out, mail me and I give you the password
>> to the betatest download area,

>>     http://www.engelschall.com/u/sb/download/bnp/

> I probably don't have time to evaluate something in detail right now, I'm
> afraid, as the system that I have is currently mostly working and is doing
> what I need it to do and I have to move on to other projects.  But I'll
> keep an eye on this.

Anybody else who wants to take a look is greatly welcomed, of course!

The tool automatically installs most of CPAN in one go if you like (that's
the big advantage over CPAN.pm); no more typing in of commands into the
console for hours anymore! (The tool executes some 3,200 commands for this -
commands you would otherwise have to type in manually!)

Best regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: 20 Sep 1998 17:48:45 -0400
From: jete@dgs.dgsys.com (Jete Software Inc.)
Subject: Where is perl debugger GUI (tkperl)??
Message-Id: <6u3t7t$ruk@dgs.dgsys.com>

I had the URL for the site where someone was working on an open source
perl debugger GUI (this is not the ActiveWare version), which is implemented
in tkperl. But I managed to lose the URL.

Can someone please supply the URL for it.

thanks

-- Norman


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

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 3794
**************************************

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