[8780] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2398 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 23 00:07:40 1998

Date: Wed, 22 Apr 98 21:01:38 -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, 22 Apr 1998     Volume: 8 Number: 2398

Today's topics:
    Re: Removing spaces from a variable, how? <danboo@negia.net>
    Re: Removing spaces from a variable, how? <danboo@negia.net>
    Re: RMS should be invited to O'Reilly's "Free Software  <meo@rru.com>
    Re: RMS should be invited to O'Reilly's "Free Software  (Ilya Zakharevich)
    Re: Sending a text file via perl (brian d foy)
    Re: Setting environment variables 6xtippet@CyberJunkie.com
    Re: Setting environment variables <jdf@pobox.com>
        Short circuit predicates based on existence or definedn <glew@cs.wisc.edu>
    Re: Time : Year2000 & 2038 code question (John Moreno)
        where's the faq? <eckje@rhodes.edu>
    Re: where's the faq? <quentin@jihad.amd.com>
    Re: WWW security in a learning enviroment <beske@worldnet.att.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Apr 1998 02:22:42 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Removing spaces from a variable, how?
Message-Id: <353D8CB2.DEE0C7EC@negia.net>

bjf wrote:
> 
> Hiya!
> 
> How do you remove all spaces ... ie ... " " .... from a variable using
> pattern-matching?

if by pattern, you mean regular expression, then it is not necessary.
look into the 'tr' (translation) operator instead. though typically
grouped with the regular expression material in the documentation, it
is a different beast in actuality.

> Thank you for reading this.

oh no, thank you for typing it.

-- 
dan boorstein


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

Date: Wed, 22 Apr 1998 15:29:36 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Removing spaces from a variable, how?
Message-Id: <353E4520.42E1E635@negia.net>

Quentin Fennessy wrote:
> 
> First, let me say I ran Dan's code and the numbers were very similar.
> Then I expanded the variables on which the s/// or tr/// were run to
> be larger, (10K rather than 1800), with one variable including no
> whitespace, while the other was 25% whitespace.
> 
> use Benchmark;
> 
> my $nospaces = 'X' x 10000;
> my $spaces = 'XXX ' x 2500;
> 
> timethese( 50000, {
>   'tr/// no spaces' =>  sub {
>                     $nospaces =~ tr/ //d;
>                   },
>   'tr/// w/ spaces' =>  sub {
>                     $spaces =~ tr/ //d;
                      ^^^^^^^

i'm not sure this is doing what you expect. after the first s/ //g
$spaces no longer has spaces. if you move those assignments inside the
sub declaration you will see some different results:

use Benchmark;
timethese( 5000, {
  'tr/// no spaces' =>  sub {
                    my $nospaces = 'XXXX' x 2500;
                    $nospaces =~ tr/ //d;
                  },
  'tr/// w/ spaces' =>  sub {
                    my $spaces = 'XXX ' x 2500;
                    $spaces =~ tr/ //d;
                  },
  's///  no spaces' =>  sub {
                    my $nospaces = 'XXXX' x 2500;
                    $nospaces =~ s/ //g;
                  },
  's///  w/ spaces' =>  sub {
                    my $spaces = 'XXX ' x 2500;
                    $spaces =~ s/ //g;
                  },
});

Benchmark: timing 5000 iterations of s///  no spaces, s///  w/ spaces,
     tr/// no spaces, tr/// w/ spaces...
s///  no spaces:  2 secs ( 2.12 usr  0.00 sys =  2.12 cpu)
s///  w/ spaces: 21 secs (20.83 usr  0.00 sys = 20.83 cpu)
tr/// no spaces:  2 secs ( 2.36 usr  0.00 sys =  2.36 cpu)
tr/// w/ spaces:  2 secs ( 2.39 usr  0.00 sys =  2.39 cpu)

draw your own conclusions, but it looks to me like 'tr' is usually
a safe bet for these sort of operations.

-- 
dan boorstein


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

Date: Wed, 22 Apr 1998 01:03:17 -0500
From: Miles O'Neal <meo@rru.com>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <353D8825.4F2781D4@rru.com>

nathanh@chirp.com.au wrote:
> 
> tzs@halcyon.com (Tim Smith) writes:

> You should choose GPL because none of the other license guarantees
> that the software you write today will continue to be developed as
> free software tomorrow.
> 
> Your other licenses allow free code to be hoarded.

This simply isn't true.  There are any number of ways to write a license
that allows my code to continue to be available.  Included are options
which alow others to do as tehy wish so long as they acknowledge my
rights, and a requirement that they get permission from me before doing
anything else.  In the latter case, I can be as structured or
caprcicious
as I wish in granting licenses.  In any event, *my* code is still
available
to any who wish to use it.  Nobody hoards it.

-Miles


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

Date: 22 Apr 1998 19:09:05 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6hlf8h$khr$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Eugene O'Neil
<eugene@cs.umb.edu>],
who wrote in article <6hl3a6$euf@dfw-ixnews8.ix.netcom.com>:
> >It's a difference between being generous, and being responsible. A
> >free software developer who doesn't release code under the GPL has
> >not guaranteed the software's continuing freedom.
> 
> Yes they have. The version that was RELEASED as free code will ALWAYS be free! 
> Any improvements people CHOOSE to contribute as free software will also be 
> free! Only non-free dirivative works will not be free: they wouldn't be free 
> under the GPL either, they simply wouldn't exist. Does less software make the 
> world a better place?

Unfortunately, according to RMS's lawers, this is not *that* simple.
I do believe that he has some point in requiring transfer of copyright
to FSF.  How this is logical I do not understand *exactly*, but I do
not want to ;-).

Ilya


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

Date: Tue, 21 Apr 1998 21:22:01 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sending a text file via perl
Message-Id: <comdog-ya02408000R2104982122010001@news.panix.com>
Keywords: from just another new york perl hacker

In article <353D3FE8.94951DB@state.or.us>, Glenn Schworak <Glenn.J.Schworak@state.or.us> posted:


>Any ideas on how to get InterNet Explorer to work right? Maybe by
>changing the header info?

>    print "Content-type := application/octet-stream\n";
>    print "Content-disposition := filename=\"$file_name\"\n";


those don't look like HTTP headers.  perhaps you might look at the 
HTTP specification referenced in the CGI Meta FAQ.  in short, header
line look something like

   Field-name: value

there is also lots of information on file downloading in previous
threads in comp.infosystems.www.authoring.cgi.  remember, since
HTTP doesn't care what language you use, it's not a language issue,
so protocol questions are more appropriate elsewehere.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 22 Apr 1998 17:34:20 GMT
From: 6xtippet@CyberJunkie.com
Subject: Re: Setting environment variables
Message-Id: <353e293e.69864499@news.usaor.net>

On Wed, 22 Apr 1998 00:02:40 -0400, Jeff Spray <jespray@one.net>
wrote:

>Hello list,
>    I have a problem that I need to manipulate a current environment
>variable and then set a new, previously unset variable and make it
>permanent for all subseqent shells that start.  I can get them set, but
>they are not permanent.  This must be accomplished on NT platforms
>(corporate bought them, not me).  Any help would be appreciated.  TIA
>
>--
>Jeff Spray <jespray@one.net>
>------------------------------------------------------------------------
>
>Smith and Wesson - The original point and click interface..
>------------------------------------------------------------------------
>

A process gets a copy of its parents environment variables, but I do
not know of anyway for a child to change a parents environment.

So process A creates process B.  Process B has a copy of process A's
environment.  Process B creates some environment varibles and creates
process C.  Process C gets a copy of process B's environment which
includes everything passed from process A plus the changes made by
process B. ...

When a child process dies it's copy of the environment goes with it.

I think this describes your problem.

I also think that the solution to your problem is to find another way
of passing data back to the parent process.

1. Writing the data to a file that can later be read.
2. Writing the data to a stream that can be piped.

Lee


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

Date: 22 Apr 1998 10:26:57 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Jeff Spray <jespray@one.net>
Subject: Re: Setting environment variables
Message-Id: <emypancu.fsf@mailhost.panix.com>

[posted and mailed]
Jeff Spray <jespray@one.net> writes:

>     I have a problem that I need to manipulate a current environment
> variable and then set a new, previously unset variable and make it
> permanent for all subseqent shells that start.  I can get them set, but
> they are not permanent.  This must be accomplished on NT platforms

A DejaNews search on this group with my email address as author ought
to turn up some sample code to do just what you want.  You'll need to
use the Win32::Registry module, I believe.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 22 Apr 1998 12:11:14 -0500
From: Andy Glew <glew@cs.wisc.edu>
To: Mike Haertel <haertel@ichips.intel.com>, glew@cs.wisc.edu
Subject: Short circuit predicates based on existence or definedness, not truth
Message-Id: <353E24B2.F1857DF4@cs.wisc.edu>

I am defining a language (a database sublanguage, if you care) loosely based on Perl.

One of the nicest things about Perl, I have found, is that it has existence and definedness
predicates; it has fairly good handling of undefined values (Perl undef), which is a very
convenient abstraction for databases where many entries or fields are missing.

This is rather like the NULL handling problem in databases. Perl's notation is more convenient, IMHO.

E.g. in Perl you can say the equivalent of

        IF exists(variable) THEN variable ELSE other-value

            (actually using the usual ?: syntax:   (exists $hash{key} ? $hash{key} : $othervalue)

You can say

    IF defined(variable) THEN variable ELSE othervalue
        (defined $var ? $var : $othervalue)

as well as

    IF variable THEN variable ELSE othervalue
        ($var ? $var : $othervalue)

This last has the convenient shorthand  $var||$othervalue,
which saves having to type the expression that corresponds to $var twice.
(It is out of such small savings in typing that expressivity arises.)


Problem:  Perl treats the undefined value "undef" as well as 0 as being equivalent
to 'false'. This is convenient in many situations, but not always.



One of my most frequent bugs in writing Perl is to write

    ($var||$othervalue)

when I have forgotten that $var may be a legitimate zero
- i.e. when I really mean

    (defined $var ? $var : $othervalue)
    IF defined(variable) THEN variable ELSE other value

Similarly for exists.


I believe that this error is encouraged by the conciseness of the $var||$other form,
compared to the verbosity of the full conditional expression.



I am therefore wondering if it might be useful to define (in my extended language)
shorthands for

    IF defined(var) THEN var ELSE other

perhaps      var ||| other

and similarly for the existence predicate        var :|| other.



I solicit the advice of others who may have considered this issue:
language designers, Perl users, database users.


Suggestions as to the syntax seem desirable:

    existsVar ||| other
    existsVar :|| other
    definedVar ::|| other
    existsVar ||:: other
    definedVar ||: other
    truthVar || other


(Yes, I am aware ofg the conflict with SQL's || operator)


----


Please email responses; I don't read these newsgroups.







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

Date: Wed, 22 Apr 1998 14:41:32 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: Time : Year2000 & 2038 code question
Message-Id: <1d7vune.w3wkp1lf1rprN@roxboro0-010.dyn.interpath.net>

Bojan Landekic <bland@sprint.ca> wrote:

> Brad Baxter wrote:
> 
> > If I'm reading this right, the author knows that the year will not be less
> > than 70 until the year 2000, when the year will be '00'.  Therefore, he is
> > adding 2000 instead of 1900.
> 
> That's right I think.. but the same problem we will experience again in 2100,
> 2200....xx00 years will have this.. A solution for "all" of them needs to be
> found, not just for the 2k problem, which I think is what most companies are
> concerned, just watch in 2100, the same problem will come again (-:..
> sheeshh...

That's wrong - it won't be 00 in 2000 and it won't be 00 2100 and it
won't be 00 in 2200 either (I make no claims about 2300 - the programers
then are going to be incompetent and will probably screw it up, so
remember: if you find yourself using a computer in 2290-2390 ONLY use
programs that are more than 50 years old).

-- 
John Moreno


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

Date: Tue, 21 Apr 1998 11:50:15 CDT
From: Jay Eckles <eckje@rhodes.edu>
Subject: where's the faq?
Message-Id: <Pine.PMDF.3.95.980421114949.121743A-100000@rhodes.edu>

Where do I find the faq (and archive if there is one) for this newsgroup?

Jay Eckles
www.ecklesweb.com



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

Date: 22 Apr 1998 08:51:45 -0500
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: where's the faq?
Message-Id: <ximaf9eezgu.fsf@jihad.amd.com>


The Perl distribution includes the Perl FAQ in POD format.
Check in your src directory for pod/perlfaq*.pod.

It should also be available via perldoc:

	perldoc perlfaq
	perldoc perlfaq1
	perldoc perlfaq...
	perldoc perlfaq9

And on the web at:

	http://language.perl.com/faq/index.html

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Wed, 22 Apr 1998 09:31:02 -0400
From: Bryan Beske <beske@worldnet.att.net>
Subject: Re: WWW security in a learning enviroment
Message-Id: <6hkrg3$stv@bgtnsc02.worldnet.att.net>

Your question really has its roots in the "statelessness" of
the web and not perl. This is a highly debated issues and
the passing of "identification" information is a common technique
around the statelessness of the web.

I would recommend that you read:

    http://www.w3c.org/TR/WD-session-id

for more background.

Short of creating some sort of hashed unique ID that you manage,
there is no easy way around the statelessness of the web.

b^2



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2398
**************************************

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