[16694] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4106 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 23 14:06:01 2000

Date: Wed, 23 Aug 2000 11:05:28 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967053928-v9-i4106@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 Aug 2000     Volume: 9 Number: 4106

Today's topics:
        @ARGV with ( and ) symbols in it <graham.wood@iona.com>
    Re: @ARGV with ( and ) symbols in it tebrusca@my-deja.com
        Arrays, hashes wtih braces vanis@my-deja.com
    Re: Arrays, hashes wtih braces <tina@streetmail.com>
    Re: Arrays, hashes wtih braces <tina@streetmail.com>
    Re: Arrays, hashes wtih braces <tina@streetmail.com>
    Re: Assistance needed updating a script blindemann@my-deja.com
    Re: Associative arrays <hartleh1@westat.com>
    Re: Associative arrays <lr@hpl.hp.com>
    Re: Best General HTTP Proxy? (Randal L. Schwartz)
    Re: Best General HTTP Proxy? (Abigail)
    Re: Best General HTTP Proxy? <mkruse@netexpress.net>
    Re: Best General HTTP Proxy? <flavell@mail.cern.ch>
    Re: Best/Easiest SQL Server friendly module? <gellyfish@gellyfish.com>
    Re: Best/Easiest SQL Server friendly module? <amonotod@netscape.net>
        Calling a Perl Script blindemann@my-deja.com
    Re: Calling a Perl Script <amonotod@netscape.net>
    Re: Callling Java method with Perl skesavan@my-deja.com
        database for large number of keys? nejeian@my-deja.com
        Deleteing a file blindemann@my-deja.com
        Deleting all elements between ZZZ and YYY <ed@aw.sgi.com>
    Re: Functions and reference notation. (Abigail)
    Re: how can I optimize a tied hash for speed <iltzu@sci.invalid>
    Re: how to generate unreadable from readable perl code (Malcolm Dew-Jones)
    Re: Intercepting STDERR under in95 (Malcolm Dew-Jones)
        LDAP and authentication <ajmas@bigfoot.com>
    Re: looking for taint resources tebrusca@my-deja.com
        MIME-Lite Build Error jdaves@gilanet.com
        Modifying @INC: my problem and solution (any comment?) hasant@trabas.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 23 Aug 2000 17:18:20 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: @ARGV with ( and ) symbols in it
Message-Id: <8o0tt8$cjt$1@bvweb.iona.com>

I'm attempting to write a script that will accept OS/390 dataset names and
members thereof as input.  The command line will look like:

process.pl GWOOD.UTIL.JCL(STARTUP)

Sadly perl is complaining that it is getting a "(" where it was expecting a
newline.

Can anyone point me at the docs that will explain how to fool perl into
accepting "(" and ")" as valid parts of a command line argument?

I've had a look in perldoc perlvar and at perl -h but didn't see anything
obvious there.


Thanks

Graham




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

Date: Wed, 23 Aug 2000 17:22:03 GMT
From: tebrusca@my-deja.com
Subject: Re: @ARGV with ( and ) symbols in it
Message-Id: <8o1173$v2u$1@nnrp1.deja.com>

In article <8o0tt8$cjt$1@bvweb.iona.com>,
  "Graham Wood" <graham.wood@iona.com> wrote:
> I'm attempting to write a script that will accept OS/390 dataset
names and
> members thereof as input.  The command line will look like:
>
> process.pl GWOOD.UTIL.JCL(STARTUP)
>
> Sadly perl is complaining that it is getting a "(" where it was
expecting a
> newline.

Works for me on NT, what are you doing with the ARGS??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 17:01:39 GMT
From: vanis@my-deja.com
Subject: Arrays, hashes wtih braces
Message-Id: <8o1015$ti5$1@nnrp1.deja.com>

Hi,

I played around with creating an array using braces..

@cars = {"corvette", "firebird", "camaro", "pony"}; #which is misfit?
$cnt = @cars;

print $cnt;       #prints '1'
print "@cars";    #prints 'HASH(0x80c118c)'
print @cars;      #prints 'HASH(0x80c1180)'

It seems to count the values as a single string..This becomes apparent
when the same is tried with a hash

%cars = {"corvette", "firebird", "camaro", "pony"};

print %cars;     #with warnings turned on, the following is printed

Odd number of elements in hash list at t.pl line 5 (#1)

(S) You specified an odd number of elements to a hash list, which is
odd, because hash lists come in key/value pairs.

Just curious to know what it's doing, and the difference(s) between
using braces{} and parentheses()..besides the fact that parentheses are
what works.. thanks

-Robert-


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 23 Aug 2000 17:48:44 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Arrays, hashes wtih braces
Message-Id: <8o12ps$9oj46$11@ID-24002.news.cis.dfn.de>

hi,
vanis@my-deja.com wrote:

> I played around with creating an array using braces..

> @cars = {"corvette", "firebird", "camaro", "pony"}; #which is misfit?
> $cnt = @cars;

read perldoc perl;var about creating arrays and hashes.
you are creating an anonymous hash here, and you assign it
to @cars, so $cars[1] contains a hash reference.

> print $cnt;       #prints '1'
> print "@cars";    #prints 'HASH(0x80c118c)'
> print @cars;      #prints 'HASH(0x80c1180)'

yup, as I said.

> It seems to count the values as a single string..This becomes apparent
> when the same is tried with a hash

> %cars = {"corvette", "firebird", "camaro", "pony"};

here you are creating an anonymous hash and assign it to
a hash, so it's like
%hash = ($hashref);
so perl tries to create a hash out of the list of values,
but it is only one, the $hashref, and you cannot build a hash
with an odd number.

> print %cars;     #with warnings turned on, the following is printed

> Odd number of elements in hash list at t.pl line 5 (#1)

yup, that's what i said.

> Just curious to know what it's doing, and the difference(s) between
> using braces{} and parentheses()..besides the fact that parentheses are
> what works.. thanks

i'm just curious what you *wanna* do.
create an array like:
my @array = (1, 3, "this is a test", 42);
my @array2 = qw(word anotherword thirdword end);

create a hash like:
%hash = (key1 => 'value1',
         key2 => 'value2');
or 
%hash = @array2;

HTH,
tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: 23 Aug 2000 17:50:11 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Arrays, hashes wtih braces
Message-Id: <8o12sj$9oj46$12@ID-24002.news.cis.dfn.de>

me again,
Tina Mueller <tina@streetmail.com> wrote:
> vanis@my-deja.com wrote:

> read perldoc perl;var about creating arrays and hashes.

oops, weird. i meant
perldoc perldata

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: 23 Aug 2000 17:52:07 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Arrays, hashes wtih braces
Message-Id: <8o1306$9oj46$13@ID-24002.news.cis.dfn.de>

Tina Mueller <tina@streetmail.com> wrote:

> read perldoc perl;var about creating arrays and hashes.
> you are creating an anonymous hash here, and you assign it
> to @cars, so $cars[1] contains a hash reference.

not a good day for programming, I guess. $cars[0], of course.
I should go home and relax...
forgive me any other errors...

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Wed, 23 Aug 2000 17:19:04 GMT
From: blindemann@my-deja.com
Subject: Re: Assistance needed updating a script
Message-Id: <8o111i$uuo$1@nnrp1.deja.com>

How should I fill in the subject?  1)Please assit me in putting the
contents of a file in a e-mail and 2) please assist me in renaming a
file and 3) please assist me in deleting a file?  This is an awful lot
to put in a subject heading!

The subject lines tells you that I am looking for assitance in updating
a script.  I go into detail in the message.  This is standard for any
post!  If flamers as yourself took more time to assist rather than
complain, something helpful might come from this group!

In article <u9n1i5jjd3.fsf@wcl-l.bham.ac.uk>,
  nobull@mail.com wrote:
> blindemann@my-deja.com writes:
>
> > Subject: Assistance needed updating a script
>
> Please use the subject line to tell us something about what you are
> asking.  Your subject line tells us nothing.
>
> > I have the portion of the script that e-mails the user already in
> > place, I just need to figure out how to add the contents of the
> > file.
>
> Add simply?  Or add as a MIME attachement?  I'm guessing you mean the
> latter.  Try using the MIME modules.
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 13:08:37 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: Associative arrays
Message-Id: <39A40515.E7496C36@westat.com>



Rafael Garcia-Suarez wrote:
> 
> Alex Buell wrote in comp.lang.perl.misc:
> >I was playing with associative arrays like so:
> >
> >%fields = ( "Member ID" => 0, "Forename" => 1, "Surname" = >2 );
Typo here                                                   ^^^

> You can reverse a hash by doing
>   %values = reverse %fields;
> See perldoc -f reverse

Just be sure the values assigned are unique or you may lose something.  
Consider: 

%favorites = ( "color" => "orange", "fruit" => "orange", "flavor" =>
"orange" ) ;

then do your reverse and all you have is a single entry with key
"orange" (and value "flavor). 

Henry Hartley


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

Date: Wed, 23 Aug 2000 10:39:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Associative arrays
Message-Id: <MPG.140dac0c3d91432498acc8@nntp.hpl.hp.com>

In article <39A40515.E7496C36@westat.com> on Wed, 23 Aug 2000 13:08:37 -
0400, Henry Hartley <hartleh1@westat.com> says...
> Rafael Garcia-Suarez wrote:

 ...

> > You can reverse a hash by doing
> >   %values = reverse %fields;
> > See perldoc -f reverse
> 
> Just be sure the values assigned are unique or you may lose something.  
> Consider: 
> 
> %favorites = ( "color" => "orange", "fruit" => "orange", "flavor" =>
> "orange" ) ;
> 
> then do your reverse and all you have is a single entry with key
> "orange" (and value "flavor). 

Which value you end up with is pure happenstance, depending on the order 
of unrolling of the hash into a flat list, which is unspecified.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 23 Aug 2000 08:35:57 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Best General HTTP Proxy?
Message-Id: <m1lmxo3s82.fsf@halfdome.holdit.com>

>>>>> "Ilmari" == Ilmari Karonen <iltzu@sci.invalid> writes:

Ilmari> In article <m1wvh89avq.fsf@halfdome.holdit.com>, Randal L. Schwartz wrote:
>> comment mode too long.  For example, as HTML, this is one long
>> comment:
>> 
>> <!-- A -- B --> still in a comment <!-- C -- D -->

Ilmari> From my reading of the HTML standard, that's a syntax violation.
Ilmari> _This_ would be one long comment:

Ilmari>          <!-- A --   --> still in a comment <!--   -- D -->

Oooh, sorry.  I put the letters in to annotate, but forgot that would
break it.

You're very right (making mental notes to himself...).

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 23 Aug 2000 15:49:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Best General HTTP Proxy?
Message-Id: <slrn8q7si9.tj3.abigail@alexandra.foad.org>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDXLVIII September
MCMXCIII in <URL:news:m1wvh89avq.fsf@halfdome.holdit.com>:
 .. 
 ..                         For example, as HTML, this is one long
 .. comment:
 .. 
 ..         <!-- A -- B --> still in a comment <!-- C -- D -->

Eh, no, it isn't. It's a syntax error. You probably mean this:

           <!-- A --   --> still in a comment <!--   -- D -->

But that's not one long comment; it is *three* comments, each of them
delimited by -- (on both sides), and separated by whitespace.



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Wed, 23 Aug 2000 11:45:43 -0500
From: "Matt Kruse" <mkruse@netexpress.net>
Subject: Re: Best General HTTP Proxy?
Message-Id: <39a3ff60$0$18142@wodc7nh0.news.uu.net>

Randal L. Schwartz <merlyn@stonehenge.com> wrote
> >>>>> "Ilmari" == Ilmari Karonen <iltzu@sci.invalid> writes:
> Ilmari>          <!-- A --   --> still in a comment <!--   -- D -->
> Oooh, sorry.  I put the letters in to annotate, but forgot that would
> break it.

I'm not sure the specs dictate whether this is allowed or not.
I understand the concept of what you're doing (multiple comments, each
starting with and ending with '--') but are you sure that '>' is a valid
character in an HTML comment?

My interpretation of the spec would be that '>' ends the comment tag,
regardless of whether it's current inside of '-- --' or not. So, your
example comment is actually invalid because it starts a comment but doesn't
end it before the closing '>' tag.

So, while this example may be interesting and challenge your brain a bit,
I'm not positive that the spec is specific enough to either allow or not
allow what you've written. Agree or disagree?

(Sorry, this is no longer perl-related, but Randal started it! ;)

--
Matt Kruse
http://www.mattkruse.com/






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

Date: Wed, 23 Aug 2000 19:31:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Best General HTTP Proxy?
Message-Id: <Pine.HPP.3.95a.1000823190926.24000A-100000@hpplus03.cern.ch>

On Wed, 23 Aug 2000, Matt Kruse wrote:

> My interpretation of the spec would be that '>' ends the comment tag,

SGML doesn't have a "comment tag".

Neither do HTML _browsers_ conform to SGML syntax, even though HTML is
supposed to be based on SGML.  

Neither does HTML have a comment "tag".  It does have a comment
syntax, which at least is compatible with SGML.  It's possible to
write HTML to a common factor so that it's compatible with popular
wowsers as well as with SGML. 

What does any of this have to do with Perl?  If you want to know the
_real_ rules, there's an SGML group.  If you want to be beaten about
the head by people who think it's more important to propagate a cargo
cult of defective answers in preference to reading a specification,
and will resort to personal vilification as soon as there seems any
risk of a technically correct answer being given, then there's an HTML
group you can visit.  I can't recommend it, though. 

Note followups set.  Anyone who wants to pursue this had better take
their own responsibility for overriding it, OK?



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

Date: Wed, 23 Aug 2000 16:23:20 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Best/Easiest SQL Server friendly module?
Message-Id: <YTSo5.165$pD2.10139@news.dircon.co.uk>

On Wed, 23 Aug 2000 06:28:26 -0400, Ryan & Treena Carrier Wrote:
> Which module should I use to interface with MS SQL Server 7.0? The
> activestate perl installation comes with win32::ODBC. Will this work?

Thats fine although you might want to consider using DBD::ODBC if you are
likely to use another database for which a DBD interface is available or
will be moving your program to a non windows environment.


/J\


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

Date: Wed, 23 Aug 2000 16:47:31 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Best/Easiest SQL Server friendly module?
Message-Id: <8o0v6s$smj$1@nnrp1.deja.com>

In article <39a3a771_1@news.cybertours.com>,
  "Ryan & Treena Carrier" <ryanc@nci1.net> wrote:
> Which module should I use to interface with MS SQL Server 7.0? The
> activestate perl installation comes with win32::ODBC. Will this work?
>
>

# odbc-sql-tool.pl
# Developed with NT Emacs 19.37 and Win32 Perl build 303 on WinNT 4.0sp3
#
# Written by Jamie Flournoy <jamie@westlake.com>
# Copyright (C) 1997 by WestLake Solutions <http://www.westlake.com>

http://demo.westlake.com/sql-tool/odbc-sql-tool.pl

HTH,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 16:35:15 GMT
From: blindemann@my-deja.com
Subject: Calling a Perl Script
Message-Id: <8o0ug2$rt9$1@nnrp1.deja.com>

OK, No doubt Im a rookie here!  Just want to know how to call a
Perl/CGI script from within my HTML page without any user action.
After the page loads, I just want the script to run automatically.  Is
there a way to do this?
Thnxs
*BOB*


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 16:38:06 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Calling a Perl Script
Message-Id: <8o0ula$rut$1@nnrp1.deja.com>

In article <8o0ug2$rt9$1@nnrp1.deja.com>,
  blindemann@my-deja.com wrote:
> OK, No doubt Im a rookie here!  Just want to know how to call a
> Perl/CGI script from within my HTML page without any user action.
> After the page loads, I just want the script to run automatically.  Is
> there a way to do this?

<!--#exec cgi="/myscript.pl?params=none&why=who%20cares"-->

> Thnxs
> *BOB*
HTH,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 16:10:27 GMT
From: skesavan@my-deja.com
Subject: Re: Callling Java method with Perl
Message-Id: <8o0t10$psl$1@nnrp1.deja.com>

In article <lByo5.167670$1h3.3076507@news20.bellglobal.com>,
  "Etienne Laverdiere" <info@digitaltango.com> wrote:
> I finaly found a JPL-08201999.tar.gz module. Can I install it on my
Active
> State distribution?

Yes, I remember seeing windows in one of the test platforms mentioned,
but I myself has not tried it on any platform!

Regards


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 17:43:44 GMT
From: nejeian@my-deja.com
Subject: database for large number of keys?
Message-Id: <8o12ga$sv$1@nnrp1.deja.com>

For a task involving keeping track of several million
unsorted codewords (alphanumeric strings <= 16 characters
in length), we need to know only whether a codeword is
already in use.

Using ActivePerl v5.6.0, build 616, on Win98.

Any suggestions for efficient database implementation?

To initialize database with all current codewords, currently
trying this:

 use DB_File;

 $txtfile = shift;
 open (TXTFILE, "<$txtfile") or die "can't open $txtfile";

 tie %DB, "DB_File", "db" or die "Cannot open file 'db': $!\n";

 while (<TXTFILE>)
 {
  chomp ($key = $_);
  $DB{$key} = 1;
 }

 untie %DB;

Takes a long time to process all the entries this way, which
is a drag since we will often be given a new set of data from
which to generate a new database. Also, faster lookups would
help.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 17:11:57 GMT
From: blindemann@my-deja.com
Subject: Deleteing a file
Message-Id: <8o10kb$uac$1@nnrp1.deja.com>

I am a PERL rookie, so this may be basic for some of you, so I
apologize in advance if it is!
I have a scprit I wrote that returns some info to the browser.  After
this is complete, I want to delete a file that contains data that was
used in running the script and returned to the browser.  At the very
end of my scprit after the html is returned to the browser, I added
unlink myfile.dat;

Evidently it deletes the file quicker then the HTML fills the page
because with the unlink at the end of my script, my data doesnt come up
in the browser.  Is there a way to prevent this?  I tried adding a
second script to delete the file and calling it in the HTML that is
returned to the browser, but that doesnt seem to work.  Any suggestions?
Thanks,
*BOB*


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 10:48:17 -0700
From: Ed Braden <ed@aw.sgi.com>
Subject: Deleting all elements between ZZZ and YYY
Message-Id: <39A40E61.C5B09F43@aw.sgi.com>

Hi,

In a text file I would like to remove all lines that exist between all
the occurances of 'ZZZ' 'YYY'. For example:

-----file example-----
laksdf
lasdf
ladf
TGT
ZZZ
want to remove
these
lines
YYY
lkasdf
la
ZZZ
want
to remove
these lines
YYY
-----end of file example----

This is easily done in sed since you can specify two addresses and
perform a delete on all lines between the two addresses but I don't see
how to do this in Perl.

Thanks in advance for any assistance that you can provide.

--Ed



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

Date: 23 Aug 2000 15:43:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Functions and reference notation.
Message-Id: <slrn8q7s7f.tj3.abigail@alexandra.foad.org>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLIX September
MCMXCIII in <URL:news:8o0k3o$437$1@lublin.zrz.tu-berlin.de>:
<> 
<> I have been known to curse Perl's flexible syntax while trying to
<> make sense of certain experts' programs as well.

That's why people love Python.

<>                                                   Someone recently
<> posted code to distribute diff(1) output to three different files.
<> Scary, I tell you.


Really? Now, whose code could that have been? ;-)


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 23 Aug 2000 17:05:02 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <967050016.2136@itz.pp.sci.fi>

In article <3997d169.3d18$1db@news.op.net>, Mark-Jason Dominus wrote:
>Probably not.   each() is usually slower than keys() because you have
>to dispatch more opcodes.  keys() just dumps the key list on the stack
>and the code to do this is written in C.

I had to see that to believe it, but it seems you're right.  If one
can use each() in list context to get both the key and the value, it
isn't more than a few percent slower, though:

#!/usr/bin/perl -w
use strict;
use Benchmark;

use vars qw(%hash);
%hash = map rand() => 1 .. 2048;

timethese 1<<(shift || 0),
  { keys => 'for my $key (keys %hash) { my $val = $hash{$key}; }',
    each => 'while (my ($key, $val) = each %hash) { }',
  };

__END__
Benchmark: timing 4096 iterations of each, keys...
      each: 40 wallclock secs (36.17 usr +  0.00 sys = 36.17 CPU)
      keys: 38 wallclock secs (34.75 usr +  0.00 sys = 34.75 CPU)

This is perl, version 5.005_03 built for i386-linux

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail




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

Date: 23 Aug 2000 09:38:03 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <39a3fdeb@news.victoria.tc.ca>

If you're writing your own code and want to obfuscate later and the
obfuscator can't parse some of your code, then add hint comments for the
obfuscator to the sections or lines that cause problems.  

e.g. orginal code might look something like

	$regular_perl_code = $goes_here.

	($harder = $to_parse ) =~ s%$old%$new%;  #OBFUSCATE:HINT:s%

	#OBFUSCATE:START_BLOCK:HINT:xxx,yyy
	
		# harder to parse code goes here, obfuscator uses the 
		# indicated hints to parse it correctly

	#OBFUSCATE:END_BLOCK




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

Date: 23 Aug 2000 09:48:48 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Intercepting STDERR under in95
Message-Id: <39a40070@news.victoria.tc.ca>

Sébastien Cottalorda (sebastien.cottalorda1@libertysurf.fr) wrote:
: Hi all,

: I'm trying to intercept the STDERR of a DOS command using OPEN(FH,"$command
: |") ...
: but I didn't manage at yet.
: I only get STDOUT   --> Nothing in error cases

I don't think you can trap STDERR of a DOS command in windows 95 without
additional work.

You could open a wrapper program that redirects stderr and then execs its
parameter.  You might be able to do this with a shell (bash or sh)

Then call the wrapper with the command as a parameter

	OPEN(FH,"mywrapper.exe $command|") or die $!;





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

Date: Wed, 23 Aug 2000 15:17:52 GMT
From: Andre-John Mas <ajmas@bigfoot.com>
Subject: LDAP and authentication
Message-Id: <8o0pu9$luj$1@nnrp1.deja.com>

Could someone tell me which is the recommended LDAP module to use,
the one located at: http://miso.wwa.com/~donley/ or the mozilla
solution at http://www.mozilla.org/directory/perldap.html.

Next, does anyone have any code that would show me how to use
the LDAP module for authentication purposes?

Andre

--
http://www.bigfoot.com/~ajmas/


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 16:09:00 GMT
From: tebrusca@my-deja.com
Subject: Re: looking for taint resources
Message-Id: <8o0sua$ppq$1@nnrp1.deja.com>

In article <slrn8q7nb1.5ap.mgjv@martien.heliotrope.home>,
  mgjv@tradingpost.com.au wrote:

Thanks for the excellent advice.

For the record:

My OS  : NT and IRIX, why would it matter for this thread?
My App : Website for uploading files into a database.

I wanted to make it very secure so all my new sites could use
the lessons learned.  Hence, I'm looking for the silver bullet, but
I should be building traps on a per creature basis....






Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 15:23:50 GMT
From: jdaves@gilanet.com
Subject: MIME-Lite Build Error
Message-Id: <8o0q9b$mbg$1@nnrp1.deja.com>

Hi, all. I'm having problems building the MIME-Lite module. I can make
just fine, no errors or warnings or anything, but make test says:
   t/addrs. . .OK
   t/data. . . dubious
        Test returned status 0 (wstat 11, 0xb)
   t/head . . .OK
   t/verify. . .OK

I'm using MIME-Lite-2.102, perl 5.004_04. MIME-Lite supposedly doesn't
need any additional modules. Do I need to upgrade to perl 5.6?
(Incidentally, As far as I can tell, the previous stable release is
5.004_05, what happened between that and 5.6?).

Thanks for any help. . .


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 16:57:45 GMT
From: hasant@trabas.com
To: bandung-pm-list@happyfunball.pm.org
Subject: Modifying @INC: my problem and solution (any comment?)
Message-Id: <8o0vps$te2$1@nnrp1.deja.com>

The Problem

Determine a non-standard module path dynamically
in the scripts.


The Requirement Specs

-   There's such an environemnt where a set of
    application with its certain file structure
    under a base/root directory.
-   This application has private modules located
    in a dedicated directory under the basedir
    and for one or another reason can't be placed
    in the standard module paths.
-   The scripts are located in separated
    (may-be-nested) directory with the same level
    as modules directory.
-   So the structure can be:

        APPL_BASE_DIR/
            private_modules/
                Module1.pm
                Module2.pm
                    Others/
                        Module3.pm
                .
                .
                And_So_On.pm
            perl-scripts/
                s1.pl
                s2.pl
                dir1/
                    s3.pl
                    dir2/
                        s4.pl
                        s5.pl
                dir2/
                    s6.pl


The (alternative) Solutions

Let's assumme that names in the above example
above are real and that `APPL_BASE_DIR' is
located under `/usr/local';

1.  use lib '/usr/local/APPL_BASE_DIR/private_modules';

    The statement above is hardcoded in every single
    script. So when I move the application to
    `/home/hasant/public_html', I need to change the
    path in all the scripts. Of course, it can be done
    with inplace-edit method recursively.

    And when there's a couple of developers working with
    their own path of CVS working/testing directories,
    they all must modified the line. No, thanks.

2.  use blib 'private_modules';

    First, the blib module is not for production
    environent. And secondly, it's limited up to
    5 up/down levels of searching.

3.  use FindBin '$Bin';
    use lib "$Bin/../private_modules";

    For all scripts I must carefully count how many
    `..' I need for each script and must re-count
    when I move a script to a different directory.
    Thanks, I think I pass :-)


The Proposal

So I came up with a little module -- temporarily
called `BaseLib' -- as my attempt to fulfill the
requirement. I don't think it solves the problem
elegantly but it satisfies the specs (well, my
specs :-)

The description below is intended to provide
argument for discussing a better solution as I'm
sure there's a lot of much better solutions than
I could think of.

BaseLib optionally takes two arguments in the use()
statement: BASEDIR and LIBDIR. From the above
situation, all scripts need to say:

    use BaseLib qw(APPL_BASE_DIR private_modules);

wherever the scripts located, wherever `APPL_BASE_DIR'
is put under. But we'll soon fall back the same
situation when we change the name of BASEDIR and/or
LIBDIR. But (again), that's a different level of
decision.

What it basically does is modifying the @INC array
in import() subroutine based on the passed in
parameters. It defines default value for BASEDIR:
`appl_root' (subjected to change), and for LIBDIR:
`lib' (seems to be OK).

First it gets the full path to the running script
directory and stores it in global package variable.
I think this variable as a bonus for the scripts.

 require FindBin;
 ($BaseLib::BaseDir = $FindBin::Bin) =~ s{^([\w/.,-]+)$}{$1};


The regex usage is for satisfying the taint mode
since it could come from backtick operation (of
course the scripts need to do other things
concerning taint mode (is it true?))

It then extracts the base dir, saves it up to
what BASEDIR contains and forgets the rest.

    my $root = shift || 'appl_root';
    $BaseLib::BaseDir =~ s/^(.*\b$root\b).*/$1/;

And finally adds the private module path to
@INC array, well, if the path does exist.

    my $lib = shift || 'lib';
    if (-e "$BaseLib::BaseDir/$lib" && -d _) {
        unshift @INC, "$BaseLib::BaseDir/$lib";
    }

Putting it all together the written (very short)
version is:

    package BaseLib;
    use strict;
    $BaseLib::VERSION = '0.01';
    sub import {
        my $package = shift;
        require FindBin;
        ($BaseLib::BaseDir = $FindBin::Bin) =~ s{^([\w/.,-]+)$}{$1};
        my $root = shift || 'appl_root';
        $BaseLib::BaseDir =~ s/^(.*$root).*/$1/;
        my $lib = shift || 'lib';
        if (-e "$BaseLib::BaseDir/$lib" && -d _) {
            unshift @INC, "$BaseLib::BaseDir/$lib";
        }
    }
    1;


Availability

I haven't put this module on CPAN since it's
very premature. But anyone can review it by
downloading it from:

    http://www.zp.f2s.com/perl/modules/BaseLib-0.01.tar.gz


The Caveats

I only tested this module in the following environment:
    - Perl 5.005_03
    - Linux RH 6.2 (2.2.14)

This may not work (yet) if used with:
    - Other operating system (for paths separator)
    - mod_perl enabled Apache (for global variable)

BaseLib currently doesn't care whether the path to
the lib is in @INC already.

There's a potensial problem if along the path name
to the running script, a directory with the same
name as the real base directory exists.

The pattern in the first regex substituion needs
to be more accommodative.

My last question, is a module really worth it?


Well, that's it.
Thanks for everyone's attention and/or comments.

Regards,
hasant


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4106
**************************************


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