[13020] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 430 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 9 12:17:19 1999

Date: Mon, 9 Aug 1999 09:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 9 Aug 1999     Volume: 9 Number: 430

Today's topics:
        ANNOUNCE: MPEG::MP3Play 0.05 <joern@netcologne.de>
    Re: CGI Perl Properties (Bart Lateur)
    Re: CGI Perl Properties <uri@sysarch.com>
    Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library (Greg Bacon)
    Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library (Greg Bacon)
    Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library (Anno Siegel)
        creating directories as needed (Steve .)
    Re: creating directories as needed <tom.kralidis@ccrs.nrcanDOTgc.ca>
    Re: creating directories as needed (Michel Dalle)
        Creating variables on the fly with CGI.pm? <vlad@doom.net>
    Re: diff in perl? <elaine@chaos.wustl.edu>
    Re: diff in perl? <c4jgurney@my-deja.com>
    Re: Effective Perl Programming? <tmornini@netcom9.netcom.com>
    Re: Effective Perl Programming? <elaine@chaos.wustl.edu>
    Re: exists problem <gene@tekdata.com>
    Re: exists problem (Anno Siegel)
    Re: exists problem <uri@sysarch.com>
    Re: How? CPAN PODs? (llornkcor@earthlink.net)
    Re: Nicer Way <admin@gatewaysolutions.net>
    Re: Nicer Way <uri@sysarch.com>
    Re: Perl windows admin question. (Michel Dalle)
        Perlcc where can I find this??? xombiex@my-deja.com
    Re: Perlcc where can I find this??? <elaine@chaos.wustl.edu>
    Re: Quick Question :) <uri@sysarch.com>
    Re: Where to find help other than perldoc and books. (Greg Bacon)
    Re: Where to find help other than perldoc and books. (Greg Bacon)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 9 Aug 1999 15:34:29 GMT
From: Joern Reder <joern@netcologne.de>
Subject: ANNOUNCE: MPEG::MP3Play 0.05
Message-Id: <7omse5$c1u$1@play.inetarena.com>


I just uploaded version 0.05 of MPEG::MP3Play to CPAN:

  http://www.perl.com/CPAN/modules/by-module/MPEG/

This module uses the Xaudio SDK for the MPEG stuff. It offers a simple
OO interface to all essential functions of the Xaudio library. The
Xaudio
SDK is not part of this distribution so get and install it first
(http://www.xaudio.com/)

>From the README...

BASIC CONCEPT
    The concept of the Xaudio async API is based on forking an extra
    process (or thread) for the MPEG decoding and playing. The
    parent process controls this process by sending and recieving
    messages. This message passing is asynchronous.

    This module interface provides methods for sending common
    messages to the MPEG process, eg. play, pause, stop. Also it
    implements a message handler to process the messages sent back.
    Eg. every message sent to the subprocess will be acknowledged by
    sending back an XA_MSG_NOTIFY_ACK message (or XA_MSG_NOTIFY_NACK
    on error). Error handling must be set up by handling this
    messages.

    You will find detailed information about the interface of
    this module in its POD documentation




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

Date: Mon, 09 Aug 1999 15:30:14 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: CGI Perl Properties
Message-Id: <37b0f3c8.9332416@news.skynet.be>

janshadebeach wrote:

>Hey, its me again. I would like to know what the major diffrenceses are
>between Regular Perl and CGI Perl.

The things that people come up with, sometimes, are unbelievable. You
might just as well have asked:

  I want to know the difference between a car CD and a regular CD.

	Bart.


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

Date: 09 Aug 1999 11:50:51 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: CGI Perl Properties
Message-Id: <x7wvv5c5r8.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> I am *gulp* not add*gulp*icted to *gulp* cola. I can *gulp* quit
  A> any time *gulp* I want to. *gulp* *gulp*. The stories *gulp* you
  A> hear *gulp* about me *gulp* going to the *gulp* 24 hour store
  A> *gulp* at weird times *gulp* are rumours. *gulp*. Just *gulp*
  A> rumours. And it's Ms. Hazelnut for you.

take a long deep breath. and another. there does that feel better? now
let out a big belch!! then get back to your keyboard or else!

since tcl is the cola language, shouldn't perl be the uncola language or
7up?

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 9 Aug 1999 15:47:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library
Message-Id: <7omt6u$fgi$1@info2.uah.edu>

In article <MPG.1215255d85b7eb6989df6@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:
: In article <7oform$1c$1@info2.uah.edu> on 6 Aug 1999 22:50:30 GMT, Greg 
: Bacon <gbacon@itsc.uah.edu> says...
: 
: > Well, you are redirecting, but you should fix the broken URLs along
: > your redirect chain instead of forcing the server to do it for you.
: 
: The *purpose* of the www.pobox.com server is to redirect from a 
: permanent' URL to whgerever the subscriber wishes.

Yes, I'm aware of this, but look at the content of the Location: header
returned when you retrieve his pobox URL.

: > Trailing slashes aren't optional when a URL addresses a directory.
: 
: Huh?  I can't find anything about that in the RFC, and I know it isn't 
: required.  It may be desirable for efficiency, to avoid a redirection.

Consider systems in which files and directories populate separate
namespaces.

Greg
-- 
>This is my opinion that Perl should allow user-defined operators.

Gosh, what a lovely idea.  NOT.
    -- Tom Christiansen in <199907142341.RAA13894@jhereg.perl.com>


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

Date: 9 Aug 1999 15:51:50 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library
Message-Id: <7omtem$fgi$2@info2.uah.edu>

In article <Pine.HPP.3.95a.990807115445.1833B-100000@hpplus03.cern.ch>,
	"Alan J. Flavell" <flavell@mail.cern.ch> writes:
: URLs ending in /foo and /foo/ are quite distinct, and could in principle
: return two quite different and valid resources: the fact that this is
: unusual and even thought by some to be perverse depends only on an
: accident of the unix filesystem structure: to someone familiar with
: VAX/VMS it would seem quite natural ;-)

ObPerl: Consider, for example, the difference between these URLs:

    http://www.perl.com/CPAN
    http://www.perl.com/CPAN/

Hrm.  It looks like the CPAN selector is broken. :-(  Is this
intentional?

Greg
-- 
When the speaker and he to whom he is speaks do not understand, that is
metaphysics.
    -- Voltaire


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

Date: 9 Aug 1999 16:01:43 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: CRAP-7 ATTN:  Article 002 - HTTP Cookie Library
Message-Id: <7omu17$li6$1@lublin.zrz.tu-berlin.de>

Greg Bacon <gbacon@cs.uah.edu> wrote in comp.lang.perl.misc:
>-- 
>When the speaker and he to whom he is speaks do not understand, that is
>metaphysics.
>    -- Voltaire

This is highly self-referential.  Or there's an "is" too much and an
"each other" missing in this sentence.

Anno


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

Date: Mon, 09 Aug 1999 15:08:30 GMT
From: syarbrou@nospam.enteract.com (Steve .)
Subject: creating directories as needed
Message-Id: <37aeedb5.150638293@news.enteract.com>

I have a config file with a list of things to do.  For each of those
things I need to make sure a directory is created or exists with the
same name as what is placed in the config file.  How would I make sure
the directory exists and if it doesn't, create it?  I assume I would
use mkdir to create the directory if it failes say on an opendir, but
wanted to check if that was the best way to do it.  THanks.

Steve

Newsgroup replies preferred.  Remove nospam when responding thru
email.


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

Date: Mon, 09 Aug 1999 11:21:42 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: creating directories as needed
Message-Id: <37AEF206.CC083FEA@ccrs.nrcanDOTgc.ca>

Could you show a few example lines from this 'config' file?  It would
help understanding your question.

 ..Tom
"Steve ." wrote:
> 
> I have a config file with a list of things to do.  For each of those
> things I need to make sure a directory is created or exists with the
> same name as what is placed in the config file.  How would I make sure
> the directory exists and if it doesn't, create it?  I assume I would
> use mkdir to create the directory if it failes say on an opendir, but
> wanted to check if that was the best way to do it.  THanks.
> 
> Steve
> 
> Newsgroup replies preferred.  Remove nospam when responding thru
> email.

-- 

-----------------------------------------------------------------------------------------
Tom Kralidis                                  Geo-Spatial Technologist 
Canada Centre for Remote Sensing              Tel: (613) 947-1828
588 Booth Street , Room 241                   Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7                     http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------


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

Date: Mon, 09 Aug 1999 15:45:27 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: creating directories as needed
Message-Id: <7omt6u$e6g$2@news.mch.sbs.de>

In article <37AEF206.CC083FEA@ccrs.nrcanDOTgc.ca>, Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
>"Steve ." wrote:
>> 
>> I have a config file with a list of things to do.  For each of those
>> things I need to make sure a directory is created or exists with the
>> same name as what is placed in the config file.  How would I make sure
>> the directory exists and if it doesn't, create it?  I assume I would
>> use mkdir to create the directory if it failes say on an opendir, but
>> wanted to check if that was the best way to do it.  THanks.

You don't need an opendir to check the existence of a directory.
Just use '-d', as explained in the '-X' part of perlfunc.

Have fun,

Michel.


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

Date: 9 Aug 1999 12:09:59 GMT
From: <vlad@doom.net>
Subject: Creating variables on the fly with CGI.pm?
Message-Id: <7omgen$t6r$1@news.servint.com>

I was wondering if anyone knew if the following code is valid or not.
I have a website with a form that contains a lot of input fields, they
each have there own name and I want to create variables using the same 
name for easier tracking..

I used to create variables for them the following way:

my $var1 = param("var1");
my $var2 = param("var2");
my $var3 = param("var3");
etc.

The above ended up being a page or two worth of declarations, so instead
I did this, which is a lot smaller obviously:

my @fields = param ();

for (@fields) {
	${$_} = param ($_);
}


This works just fine when I don't use -w and use strict.  But breaks when I do,
the problem is I can't "my" ${$_} and if do, I usually end up with errors like:

Can't use global $_ in "my" at test.cgi line 8.

And even if I could my them, wouldn't they stay private in the for loop.

I've tried many different ways and none work. So I was wondering, is there a way to
do the above with -w and use strict on?  Or is there another way of doing this other
than declaring everything? Or should I not be writing code like this to begin with :)

Here are the vitals:
[vlad@host cgi-bin]# perl -v |grep ver
This is perl, version 5.004_04 built for i386-linux

Here is some small html and perl (without -w or use strict) to play with if anyone is
interested. Thanks.

test.html:

<html>
<form method=GET action=/cgi-bin/test.cgi> 
<input name=var1 value=""> <input name=var2 value=""> 
<input name=var3 value=""> <input type=submit name=action value=submit>
</form>
</html>


test.cgi:

#!/usr/bin/perl

use CGI qw(param header);

my @fields = param ();
	for (@fields) {
		${$_} = param ($_);
}


print header ();
print "<html>var1 is $var1 var2 is $var2 var3 is $var3</html>";

-v


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

Date: Mon, 09 Aug 1999 11:35:58 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: diff in perl?
Message-Id: <37AEF532.A1CB5A1C@chaos.wustl.edu>

Andreas Fehr wrote:
> <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
> >diff file1 file2 > difference.txt
> >
> >I have a script that creates two files on the fly, and I want to compare
> >them, and output the differences to file, similar to diff.
> >
> And there is the module Algorithm::Diff on CPAN

If you are using Unix, you also might try 'comm' which I use all the
time for such things. MJD's module is handy for more complex diff analysis...IMHO.

e.


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

Date: Mon, 09 Aug 1999 15:41:40 GMT
From: Jeremy Gurney <c4jgurney@my-deja.com>
Subject: Re: diff in perl?
Message-Id: <7omsrh$j6q$1@nnrp1.deja.com>

In article <37AEDE89.DB72BE0C@ccrs.nrcanDOTgc.ca>,
  Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
> Hi,
>
> What's the best way to do this in Perl?
>
> diff file1 file2 > difference.txt
>
<snip etc>

The Unix Reconstruction Project (http://language.perl.com/ppt/what.html)
has a version of diff written in perl for portability.

http://language.perl.com/ppt/src/diff/index.html

Personally I find it very useful.

HTH,

Jeremy Gurney
SAS Programmer  |  Proteus Molecular Design Ltd.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 9 Aug 1999 15:06:14 GMT
From: Tom Mornini <tmornini@netcom9.netcom.com>
Subject: Re: Effective Perl Programming?
Message-Id: <7omqp6$i6f@dfw-ixnews14.ix.netcom.com>

hoz <hoz@rocketmail.com> wrote:

: What is the general consenus about this book?

I can't speak to that, but I loved it.

: Is it a must have like the camel?

It's not a complete reference, but I'd hate to be without it!

: Will it dramatically improve my
: skill/knowledge?

Depends on how much you already know.

-- Tom Mornini
-- InfoMania Printing & Prepress


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

Date: Mon, 09 Aug 1999 11:27:02 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Effective Perl Programming?
Message-Id: <37AEF31A.5715B6FC@chaos.wustl.edu>

[courtesy copy to original author]

> What is the general consenus about this book?
> Effective Perl Programming:  Writing Better Programs With Perl
> by Joseph N. Hall

People on amazon.com seem to like it...
http://www.amazon.com/exec/obidos/ASIN/0201419750/o/qid=934211733/sr=8-1/002-0349356-3898241

Also, you might check out 
http://www.netaxs.com/~joc/perlbooks.html 
http://www.netaxs.com/~joc/perlbooks/0201419750.html
http://www.effectiveperl.com/

> Is it a must have like the camel? Will it dramatically improve my
> skill/knowledge?

Well, the camel is the camel and it really isn't interchangeable with
any other reference. If you are a beginner I would recommend "Learning
Perl", but if you are already into Perl to some degree, then I would
recommend EPP over Advanced Perl Programming and others. Be sure to get
the 2nd printing with the larger type on the spine if you head for the
bookstore to purchase a copy.

enjoy.

e.


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

Date: Mon, 09 Aug 1999 10:21:36 -0500
From: Gene LeFave <gene@tekdata.com>
Subject: Re: exists problem
Message-Id: <37AEF200.CF302894@tekdata.com>

Tom,

Thanks for your reply.   I finally located the error log and perl gives
a message about illegal tokens  exists $in

Is it possible that the exists function doesn't exist in earlier
versions?   Since I found it in a perl book on version 5 I thought it
would work on all 5.x versions.

This is only one line in pages of perl code so I can't really change the
way $in is used.   It is created by a cgi library script.  I have
searched numerous books, online samples, etc.  and I can't find any
other way to do this.  The problem is that I need to distinquish between
the Econf parameter being present or not.  If it is present a null value
is perfectly acceptable.   In other places in the source the phrase:   

     $something  = $in {'something'}   
is used frequently.    I originally used this but there is no
distinction that I can be find between   $in{'something'} =  ""    and
$in{'something'} being undefined.    

Since the script is in an application that we supply to hundreds of
customers, it is extremely desirable that it works in all 5.x perls'. So
I'm looking for a version insensitive way to do this.

As you may have guessed, I've inherited this code from a long gone
employee.    This is my only exposure to perl,  and I thought I was
beginning to "get" it,  until this problem showed up.  

Gene



Tom Phoenix wrote:
> 
> On Fri, 6 Aug 1999, root wrote:
> 
> > if  (  exists   $in { 'Econf'}  )  {
> >     print  $HANDLE 'Econf  $in{'Econf'}\r';
> 
> Don't put single quotes in a single-quoted string, and don't use
> single-quoted strings when you want interpolation. And do you want HANDLE
> or $HANDLE? Did you really mean "\r"? Maybe you want this?
> 
>     print HANDLE "Econf $in{Econf}\n";
> 
> >   &wait'ok }
> 
> This looks like it was borrowed from some _old_ code. Maybe you want
> &wait::ok.
> 
> > $in  contains a list of arguments from a web server.
> 
> Do you mean %in?
> 
> > The system it fails on is running perl 5.002
> 
> Since that's a version of Perl that's older than the Spice Girls, you
> should see about upgrading.
> 
> > I want to execute the print statement iff  the  Econf   variable existed
> > on the page  coming back from a web server.
> 
> See the docs for the CGI module, or a similar module.
> 
> > I was under the impression that the exists statement will search the
> > $in array and return false if the Econf member wasn't there.
> 
> If you replace '$in array' with '%in hash', you'll be well on your way
> towards enlightenment. Have fun with Perl!
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: 9 Aug 1999 15:51:59 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: exists problem
Message-Id: <7omtev$lg0$1@lublin.zrz.tu-berlin.de>

Gene LeFave  <gene@tekdata.com> wrote in comp.lang.perl.misc:
>Tom,
>
>Thanks for your reply.   I finally located the error log and perl gives
>a message about illegal tokens  exists $in

Could you reproduce the error message exactly?  "token" appears
exactly once in perldiag, and not in a message.

>Is it possible that the exists function doesn't exist in earlier
>versions?   Since I found it in a perl book on version 5 I thought it
>would work on all 5.x versions.

It's been around far longer than perl5.

>This is only one line in pages of perl code so I can't really change the
>way $in is used.   It is created by a cgi library script.  I have
>searched numerous books, online samples, etc.  and I can't find any
>other way to do this.  The problem is that I need to distinquish between
>the Econf parameter being present or not.  If it is present a null value
>is perfectly acceptable.   In other places in the source the phrase:   
>
>     $something  = $in {'something'}   
>is used frequently.    I originally used this but there is no
>distinction that I can be find between   $in{'something'} =  ""    and
>$in{'something'} being undefined.    

With respect to hashes, you can distinguish three situations. This is
explained in perldoc -f exists.  To quote:

    print "Exists\n"    if exists $array{$key};
    print "Defined\n"   if defined $array{$key};
    print "True\n"      if $array{$key};

So you can tell the difference between a '' value and an undefined
value.

>Since the script is in an application that we supply to hundreds of
>customers, it is extremely desirable that it works in all 5.x perls'. So
>I'm looking for a version insensitive way to do this.

It's certainly not the perl version that is the problem, except
you have a buggy build (*very* unlikely).

Anno


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

Date: 09 Aug 1999 11:59:20 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: exists problem
Message-Id: <x7u2q9c5d3.fsf@home.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  >> Is it possible that the exists function doesn't exist in earlier
  >> versions?   Since I found it in a perl book on version 5 I thought it
  >> would work on all 5.x versions.

  AS> It's been around far longer than perl5.

exists came into existance with perl5. it is not in the pink camel.

  AS>     print "Exists\n"    if exists $array{$key};
  AS>     print "Defined\n"   if defined $array{$key};
  AS>     print "True\n"      if $array{$key};

  AS> So you can tell the difference between a '' value and an undefined
  AS> value.

and whether a key exists in the hash at all, without caring about its
value.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 09 Aug 1999 08:58:44 -0600
From: llornkcor@earthlink.net (llornkcor@earthlink.net)
Subject: Re: How? CPAN PODs?
Message-Id: <wk1zddova3.fsf@earthlink.net>

>This 1200 baud modem is killing me.
hmm, well, I guess its about time for an upgrade?



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

Date: Mon, 9 Aug 1999 10:09:12 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Re: Nicer Way
Message-Id: <rqtrki89kur47@corp.supernews.com>

Mabe there is somthing wrong with the way Outlook Exp. is reading the Mime
Type.
What program are you using and where can I get a copy. I've been looking for
somthing to replace Outlook!
Here is what I am looking at when I see your post.
#!/usr/bin/perl -w
use strict;

use Benchmark;

timethese( 1 << ( shift || 0 ), {
  'Scott'     => "Scott('rwxr-xr-x')",
  'Scott_a'   => "Scott_a('rwxr-xr-x')",
  'Larry'     => "Larry('rwxr-xr-x')",
  'Abigail1'  => "Abigail1('rwxr-xr-x')",
  'Abigail2'  => "Abigail2('rwxr-xr-x')",
  'Abigail3'  => "Abigail3('rwxr-xr-x')",
  'Abigail3a' => "Abigail3a('rwxr-xr-x')",
  'Abigail4'  => "Abigail4('rwxr-xr-x')",
  'Abigail4a' => "Abigail4a('rwxr-xr-x')",
  'Anno'      => "Anno('rwxr-xr-x')",
});

#####################################################################

# This is the original proposition

sub Scott {
  my $chmod = shift;
  my %ch= (r=>4, w=>2, x=>1, '-' =>0);
# $chmod =~ s/\-/k/g;
  $chmod =~
  s/(.)(.)(.)(.)(.)(.)(.)(.)(.)/$ch{$1}+$ch{$2}+$ch{$3}.
    $ch{$4}+$ch{$5}+$ch{$6 }.$ch{$7}+$ch{$8}+$ch{$9}/e;
  $chmod;
}

# And here's the original solution without table generation

use vars '%ch';
BEGIN {
  %ch= (r=>4, w=>2, x=>1, '-' =>0);
}
sub Scott_a {
  my $chmod = shift;
  $chmod =~
  s/(.)(.)(.)(.)(.)(.)(.)(.)(.)/$ch{$1}+$ch{$2}+$ch{$3}.
    $ch{$4}+$ch{$5}+$ch{$6 }.$ch{$7}+$ch{$8}+$ch{$9}/e;
  $chmod;
}

# Larry's immediate improvement

sub Larry {
  my $chmod = shift;
  ($_ = $chmod) =~ tr/rwx-/4210/;
  $chmod = '';
  $chmod .= $1 + $2 + $3 while /(.)(.)(.)/g;
  $chmod;
}

# Abigail frots it all in one statement (no s/// at all here)

sub Abigail1 {
  my $chmod = shift;
  join "" => map {eval join "+" => split file://}
    grep {length} split /(...)/   => do {$chmod =~ y.rwx-.4210.; $chmod};
}

# This might as well have been called Larry2, but Larry attributes it
# to Abigail.

sub Abigail2 {
  my $chmod = shift;
  $chmod =~ tr/rwx-/4210/;
  $chmod =~ s/(.)(.)(.)/$1 + $2 + $3/eg;
  $chmod;
}

# Using pack and ord:

sub Anno {
  my $chmod = shift;
  $chmod =~ tr/rwx-/1110/;
  $chmod =~ s/(...)/ord pack 'b3', $1/ge;
  $chmod;
}

# Abigail using the original translation table

sub Abigail3 {
  my $chmod = shift;
  my %ch = (r=>4, w=>2, x=>1, '-'=>0);
  $chmod =~ s/(.)(.)(.)/$ch{$1}+$ch{$2}+$ch{$3}/eg;
  $chmod;
}

# The same, but the generation of the translation table factored out

sub Abigail3a {
  my $chmod = shift;
  $chmod =~ s/(.)(.)(.)/$ch{$1}+$ch{$2}+$ch{$3}/eg;
  $chmod;
}

# This one doesn't need the /e modifier. Instead it  builds a more
# comprehensive translation table.

sub Abigail4 {
  my $chmod = shift;
  my %chmod =
    do {my $i; map {$_ => $i ++} qw /--- --x -w- -wx r-- r-x rw- rwx/};
  $chmod =~ s/(...)/$chmod{$1}/g;
  $chmod;
}

# Abigail4 suffers most from building the translation table each time.
# Here's a variant that builds it only once.

use vars '%chmod';
BEGIN {
%chmod = do {my $i; map {$_ => $i ++} qw /--- --x -w- -wx r-- r-x rw- rwx/};
}
sub Abigail4a {
  my $chmod = shift;
  $chmod =~ s/(...)/$chmod{$1}/g;
  $chmod;
}
__END__


--
Scott Beck
admin@gatewaysolutions.net
www.gatewaysolutions.net
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:7omk9b$l2m$1@lublin.zrz.tu-berlin.de...
> Scott Beck <admin@gatewaysolutions.net> wrote in comp.lang.perl.misc:
> >Cut-n-past of the code here gives the following error
> >---------- Perl ----------
> >syntax error at test.cgi line 61, near "file:"
> >BEGIN not safe after errors--compilation aborted at test1.cgi line 115.
>
> I have no idea how "file:" got in your text.  It is not in the code
> I posted.
>
> >I replaced
> >  join "" => map {eval join "+" => split file://}
> >with
> >  join "" => map {eval join "+" => split qw(file://)}
>
> Did you test the solution after that "correction"?  I didn't but
> it certainly did not do what it was intended to.
>
> >I ran this at the 1 iteration that you have here and
> >all the output came with the tag
> >(warning: too few iterations for a reliable count)
>
> Sure.  I think I did 4096 iterations, not one.
>
> [more benchmarks snipped]
>
> Anno




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

Date: 09 Aug 1999 11:47:41 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Nicer Way
Message-Id: <x7zp01c5wi.fsf@home.sysarch.com>

>>>>> "SB" == Scott Beck <admin@gatewaysolutions.net> writes:

  SB>   join "" => map {eval join "+" => split file://}

abigail's code via anno's post:

  join "" => map {eval join "+" => split //}


redmond does it again!!! they actually munged plain text thinking it is
a broken url. those assholes!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Mon, 09 Aug 1999 15:38:07 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Perl windows admin question.
Message-Id: <7omsp6$e6g$1@news.mch.sbs.de>

In article <7ompl1$lc5$1@lublin.zrz.tu-berlin.de>, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>Tomsic, Paul <ptomsic@pitt.edu> wrote in comp.lang.perl.misc:
>>Is there a way to access the Directory Security (permissions) and modify
>>them using Perl.
>>I've got about 200 directories that I need to set permissions on and was
>>looking for a way to access the directory permissions using Perl
>>Any help greatly appreciated.
>
>perldoc -f chmod and, probably, perldoc File::Find
>

And since this is Windows, you might also have a look at Win32::FileSecurity
and Win32::NetResource. They seem to be included in the standard ActiveState
distribution...

Michel.


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

Date: Mon, 09 Aug 1999 15:08:04 GMT
From: xombiex@my-deja.com
Subject: Perlcc where can I find this???
Message-Id: <7omqsa$hl2$1@nnrp1.deja.com>

Where can I find perlcc?  Is it available for download or is it
included in Perl 5.002?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 09 Aug 1999 11:44:26 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Perlcc where can I find this???
Message-Id: <37AEF72E.384C968D@chaos.wustl.edu>

xombiex@my-deja.com wrote:
> Where can I find perlcc?  Is it available for download or is it
> included in Perl 5.002?

perlcc was integrated into Perl 5.005 so you will need to upgrade your
version of Perl. Once installed you may use 'perldoc perlcc' to view the documentation.

e.


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

Date: 09 Aug 1999 11:43:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Quick Question :)
Message-Id: <x73dxtdko1.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> While not faster, this should work too, and it doesn't require you
  A> to figure out how many digits you need:

  A>    %t   =  map {$_ => $i ++} qw /000 001 010 011 100 101 110 111/;
  A>    $bin =  0 x (3 - length ($bin) % 3) . $bin if length ($bin) % 3;
  A>    $bin =~ s/(...)/$t{$1}/g;
  A>    $num =  oct $bin;

  A>    @t   =  qw /000 001 010 011 100 101 110 111/;
  A>    $bin =  sprintf "%o" => $num;
  A>    $bin =~ s/./$t[$1]/g;
  A>    $bin =~ s/^0+//;

if you are doing both then you can share some init code:

@t = qw /000 001 010 011 100 101 110 111/;
@t{ @t } = 0 .. $#t ;

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 9 Aug 1999 15:57:45 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Where to find help other than perldoc and books.
Message-Id: <7omtpp$fgi$3@info2.uah.edu>

In article <x74si9gb06.fsf@home.sysarch.com>,
	Uri Guttman <uri@sysarch.com> writes:
: <abigail, you fun quoting style breaks emacs justify code. it can handle
: levels of quoted indents except for yours.>

Ford is proud to offer you the Model T in any color you want provided
that you want black.

Greg
-- 
Nothing defines humans better than their willingness to do irrational things
in the pursuit of phenominally unlikely payoffs. 
    -- Scott Adams


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

Date: 9 Aug 1999 15:59:20 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Where to find help other than perldoc and books.
Message-Id: <7omtso$fgi$4@info2.uah.edu>

In article <slrn7qs0vk.8pr.abigail@alexandra.delanet.com>,
	abigail@delanet.com (Abigail) writes:
: \begin{pedantic}
: That's 'The Art of Computer Programming'.
: \end{pedantic}

Ahem!  That's `The Art of Computer Programming'. :-)

Greg
-- 
>I need to programmatically reboot a Windows NT 4.0 server using Perl.
Any command NT has a certain chance to reboot the machine, hasn't it?
    -- Abigail in <7a01hc$lvb$1@client2.news.psi.net>


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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 V9 Issue 430
*************************************


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