[17070] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4482 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 1 14:07:44 2000

Date: Sun, 1 Oct 2000 11:05:16 -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: <970423516-v9-i4482@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 1 Oct 2000     Volume: 9 Number: 4482

Today's topics:
    Re: 5.6.0 lib.pm changes. (Garry Williams)
    Re: Array functions <juex@my-deja.com>
    Re: Arrogant kid takes on huge group of programmers (wa <tony_curtis32@yahoo.com>
    Re: automatic email attachments <iltzu@sci.invalid>
    Re: Bacic Log file script - Calling it from my HTML pag <jeff@vpservices.com>
    Re: Bacic Log file script - Calling it from my HTML pag <brondsem@my-deja.com>
    Re: Bacic Log file script - Calling it from my HTML pag <brondsem@my-deja.com>
        benefits of arrays over hashes(associative arrays) and  <celliot@tartarus.uwa.edu.au>
    Re: benefits of arrays over hashes(associative arrays)  (Chris Fedde)
    Re: benefits of arrays over hashes(associative arrays)  <godzilla@stomp.stomp.tokyo>
    Re: benefits of arrays over hashes(associative arrays)  <celliot@tartarus.uwa.edu.au>
    Re: benefits of arrays over hashes(associative arrays)  <mbudash@sonic.net>
    Re: benefits of arrays over hashes(associative arrays)  (Chris Fedde)
    Re: benefits of arrays over hashes(associative arrays)  <godzilla@stomp.stomp.tokyo>
    Re: benefits of arrays over hashes(associative arrays)  (Logan Shaw)
    Re: DBI and MS-Access <jvahn@short.circuit.com>
    Re: File upload testing if it's there jim_marshall2268@hotmail.com
    Re: File upload testing if it's there yorktown5425@my-deja.com
    Re: File upload testing if it's there <flavell@mail.cern.ch>
    Re: File upload testing if it's there <godzilla@stomp.stomp.tokyo>
        Files and things jon_uk@my-deja.com
    Re: finding the structure of a hash <mauri@unixrulez.org>
    Re: flocking while using the diamond operator? tmdryden@my-deja.com
    Re: flocking while using the diamond operator? (Garry Williams)
        How to detect modules currently in use? <aphowe@netcom.ca>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 30 Sep 2000 19:42:40 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: 5.6.0 lib.pm changes.
Message-Id: <QmrB5.23$b7.2738@eagle.america.net>

On Fri, 29 Sep 2000 15:56:31 -0400, tc lewis <tcl@bunzy.net> wrote:
>so i can "use lib whatever" in perl, and with pre 5.6 perl that seemed to
>make perl look in whatever and whatever/arch for packages.  with 5.6.0, it
>seems to look in whatever, whatever/version, and whatever/version/arch,
>and not whatever/arch.
>
>however, if i use a PERL5LIB environment variable, it does look in
>whatever/arch (and whatever).

Here's what I observed: 

There's an entry in perlfaq8 (5.6.0) that seems to apply: 

	  How do I keep my own module/library directory?

	    When you build modules, use the PREFIX option when 
	    generating Makefiles:

	        perl Makefile.PL PREFIX=/u/mydir/perl

	    then either set the PERL5LIB environment variable before 
	    you run scripts that use the modules/libraries (see the 
	    perlrun manpage) or say

	        use lib '/u/mydir/perl';

	    This is almost the same as:

	        BEGIN {
	            unshift(@INC, '/u/mydir/perl');
	        }

-->	    except that the lib module checks for machine-dependent 
-->	    subdirectories.  See Perl's the lib manpage for more 
-->	    information.

Which leads us to: 

	$ perldoc lib
	...
	     The parameters to `use lib' are added to the start of the
	     perl search path. Saying

	         use lib LIST;

	     is almost the same as saying

	         BEGIN { unshift(@INC, LIST) }

	     For each directory in LIST (called $dir here) the lib module
-->	     also checks to see if a directory called
-->	     $dir/$archname/auto exists.  If so the $dir/$archname 
-->	     directory is assumed to be a corresponding architecture 
-->	     specific directory and is added to @INC in front of $dir.

So for setting PERL5LIB, we get: 

	$ mkdir lib/sun4-solaris
	$ (PERL5LIB=lib; perl -le 'for(@INC){print}')
	lib/sun4-solaris
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ mkdir lib/sun4-solaris/auto                
	$ (PERL5LIB=lib; perl -le 'for(@INC){print}')
	lib/sun4-solaris
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ 

It doesn't seem to matter if the .../arch/auto directory exists or
not; perl still includes the .../arch directory in the @INC contents.
But for using a `use lib' statement, the behavior is different: 

	$ mkdir lib/sun4-solaris                      
	$ (unset PERL5LIB; perl -le 'use lib "lib";for(@INC){print}')
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ mkdir lib/sun4-solaris/auto                                
	$ (unset PERL5LIB; perl -le 'use lib "lib";for(@INC){print}')
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ 

Perl seems to ignore the .../arch directory altogether when adding
directories with `use lib'.  But, if the version directory exists, we
get: 

	$ mkdir lib/5.6.0 lib/5.6.0/sun4-solaris
	$ (unset PERL5LIB; perl -le 'use lib "lib";for(@INC){print}')
	lib/5.6.0/sun4-solaris
	lib/5.6.0
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ mkdir lib/5.6.0/sun4-solaris/auto
	$ (unset PERL5LIB; perl -le 'use lib "lib";for(@INC){print}')
	lib/5.6.0/sun4-solaris
	lib/5.6.0
	lib
	/usr/local/lib/perl5/5.6.0/sun4-solaris
	/usr/local/lib/perl5/5.6.0
	/usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/lib/perl5/site_perl/5.6.0
	/usr/local/lib/perl5/site_perl
	.
	$ 

Again, the presence or absence of the auto subdirectory doesn't change
the behavior.  

I conclude that the documentation is in error for 5.6.0.  I think that
the behavior was deliberate in the 5.6.0 release, but I cannot find
anything to support that opinion.  

>installing packages from cpan with a PREFIX of "whatever" seems to install
>in whatever and whatever/arch.
>
>so we're a bit confused as to what changes are going on and what we can
>expect in the future.  we used to use "use lib whatever" for our perl
>stuff, but i'm suggesting PERL5LIB now instead, but we're not sure what
>the best method is.  another suggestion is to keep using "use lib
>whatever" and to instead install things with a PREFIX of whatever/version
>instead of just whatever.
>
>does this make sense?

That's how it looks to me.  Here's the behavior under perl 5.004_05: 

	$ (unset PERL5LIB;perl -le 'use lib "lib";for(@INC){print}')
	lib
	/usr/local/lib/perl5/sun4-solaris/5.00405
	/usr/local/lib/perl5
	/usr/local/lib/perl5/site_perl/sun4-solaris
	/usr/local/lib/perl5/site_perl
	.
	$ mkdir lib/sun4-solaris
	$ (unset PERL5LIB;perl -le 'use lib "lib";for(@INC){print}')
	lib
	/usr/local/lib/perl5/sun4-solaris/5.00405
	/usr/local/lib/perl5
	/usr/local/lib/perl5/site_perl/sun4-solaris
	/usr/local/lib/perl5/site_perl
	.
	$ mkdir lib/sun4-solaris/auto
	$ (unset PERL5LIB;perl -le 'use lib "lib";for(@INC){print}')
	lib/sun4-solaris
	lib
	/usr/local/lib/perl5/sun4-solaris/5.00405
	/usr/local/lib/perl5
	/usr/local/lib/perl5/site_perl/sun4-solaris
	/usr/local/lib/perl5/site_perl
	.
	$

Which is exactly what the lib manual page says should happen.  It
looks like the 5.6.0 documentation is correct under the old release.
I think it needs to be updated.  I would guess that the proceedure for
installing private modules should be to say
`--prefix=/whatever/version'.  But I'm guessing at the developers'
intent.  

-- 
Garry Williams


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

Date: Sun, 1 Oct 2000 11:03:48 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: Array functions
Message-Id: <39d77c8e@news.microsoft.com>

"Evert" <evert@coolxs.com> wrote in message
news:K5qB5.1582$gS1.10065@Typhoon.bART.nl...
Your description is less than clear

> I'm working with a database which looks like this:
[so far so good]
> I need to print out each different string in a different field of a page.
What do you mean with "field" and "page"? Perl has neither.

> To grab the last string and put it in a textfield is not a problem, but i
Again, what do you mean with textfield? This is not a standard Perl notion.

> can't make it work to put the string before the last string in a textbox.
Again, what do mean with "textbox" (is this different from a text field?)?
This is not a standard Perl notion.

jue




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

Date: 01 Oct 2000 12:54:44 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Arrogant kid takes on huge group of programmers (was Re: How to get length of scalar?)
Message-Id: <87d7hkphuj.fsf@limey.hpcc.uh.edu>

>> On Sun, 1 Oct 2000 09:19:10 +0100,
>> "Mark Carruth" <mcarruth@talk21.com> said:

> This was after I had said that as the majority of the
> web was HTML centred, I could post HTML.

This is true.  However, it is irrelevant.

WWW != internet != USENET

Communities have rules and mores for a reason.  On USENET
we cite by putting the relevant original text first and
then adding new text in the follow-up.  This style has
developed because it allows people to follow what's going
on.  Upside-down quoting doesn't.

The words "me too" followed by 200 lines of 8 fully quoted
articles is just confusing.  And noone will read it.

hth
t
-- 
Namaste!
And an "oogabooga" to you too!
                                         -- Homer Simpson


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

Date: 1 Oct 2000 16:05:48 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: automatic email attachments
Message-Id: <970415237.18221@itz.pp.sci.fi>

In article <8r7284$mcd$1@news7.svr.pol.co.uk>, Dave wrote:
>I am using someone else's server who has perl installed. Can I assume they
>already have these modules on there commercial server because I surely would
>not be able to install new modules on my web space providers server. They
>say they have full cgi-bin support.

If you can install your scrips, you can install modules too.  Just use
the "lib" pragma to specify your own module directory:

  #!/usr/bin/perl -w
  use strict;
  use lib '/home/iltzu/lib/perl';  # substitute your own path
  use My::Own::Module;

This will find the module file /home/iltzu/lib/perl/My/Own/Module.pm

To get the modules there, read perlfaq8 under the titles "How do I
install a CPAN module?" and "How do I keep my own module/library
directory?"


[Please put your replies _after_ the relevant parts or the original
 message, and remove any irrelevant quoted text.  This makes it easier
 to follow the discussion, and is the convention in most established
 Usenet newsgroup heirarchies.  Thank you.]

-- 
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: Sun, 01 Oct 2000 09:11:16 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Bacic Log file script - Calling it from my HTML page
Message-Id: <39D76224.C0E970@vpservices.com>

Dave wrote:
> 
> Ok, another basic question but I am just trying to grasp this stuff.
> 
> I have my basic cgi/perl log file script that logs the details of my
> visitors.
> 
> But how do I automatically call this script without having a submit button
> that is pressed.

This is an HTML question, rather than a Perl one, but if you have an
image tag that calls a CGI as its source, the CGI will run when the HTML
page is loaded.  You can have the CGI return a tiny invisible image to
satisfy the image tag when it is done running.

-- 
Jeff


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

Date: Sun, 01 Oct 2000 16:21:31 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Bacic Log file script - Calling it from my HTML page
Message-Id: <8r7oa6$s3a$1@nnrp1.deja.com>

In article <8r65io$7uc$1@newsg3.svr.pol.co.uk>,
  "Dave" <dave@marballs.co.uk> wrote:
> Ok, another basic question but I am just trying to grasp this stuff.
>
> I have my basic cgi/perl log file script that logs the details of my
> visitors.
>
> But how do I automatically call this script without having a submit
button
> that is pressed.
>
> Looking through tutorials I cannot seem to find how this is done.
>
> Is there no way of just writing a line in my web page that will run
the cgi
> script but still carry on displaying the page.


Make the webpage *be* a cgi script.  have it print out the text and run
the logging function:


require "my_subroutines.pm";

LogFile();

print "Content-Type:text/html\n\n";
print qq~

All your normal html

~;


OR

In your html page, include <img src="logfile.pl" width=1 size=1>  Have
logfile do the logging and then return a transparent gif.  However,
this won't work if the browser has images turned off.


>
> I hope that makes sense
>
> Thanks in advance.
> Dave
>
> --
>
>

--
Dave Brondsema


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


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

Date: Sun, 01 Oct 2000 17:09:48 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Bacic Log file script - Calling it from my HTML page
Message-Id: <8r7r4o$u6d$1@nnrp1.deja.com>



>
> In your html page, include <img src="logfile.pl" width=1 size=1>  Have
> logfile do the logging and then return a transparent gif.  However,
> this won't work if the browser has images turned off.
>

You will have to print "Content-type: image/gif\n\n" instead of
text/html


--
Dave Brondsema


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


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

Date: Mon, 2 Oct 2000 00:20:34 +0800
From: "Cameron Elliott" <celliot@tartarus.uwa.edu.au>
Subject: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39d7648e$0$31974@echo-01.iinet.net.au>

Can someone tell me which is better to use?
I cant see the point of a hash except to store something by reference to a
name which is possible to do through creative uses of arrays anyway.

Can someone please correct me if I am wrong (which is probable) and inform
me of the advantages/disadvantages of each.

Thankyou

ps.  An array is faster to access isn't it?




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

Date: Sun, 01 Oct 2000 17:04:05 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <98KB5.60$D4.135467008@news.frii.net>

In article <39d7648e$0$31974@echo-01.iinet.net.au>,
Cameron Elliott <celliot@tartarus.uwa.edu.au> wrote:
>Can someone tell me which is better to use?
>I cant see the point of a hash except to store something by reference to a
>name which is possible to do through creative uses of arrays anyway.
>
>Can someone please correct me if I am wrong (which is probable) and inform
>me of the advantages/disadvantages of each.
>
>Thankyou
>
>ps.  An array is faster to access isn't it?
>

Keep in mind the Perl moto: TIMTOWTDI.  Sure you might implement
a form of associative memory using arrays but why do it when Perl
gives you that as a primitive data type.  Hashes are useful as a
convenience when working with structured data.  Hashes are also
useful for implementing lookup tables of various types. And when
creating recursive data structures.

Once you "get" hashes you will find that they are one of the more
useful features of Perl.

chris

PS. An array access is faster than a hash access if the index is
a number.  

PPS.  You might want to read "base" and "fields" manual pages and
the stuff about pseudo-hashes in the perlref manual page.
-- 
    This space intentionally left blank


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

Date: Sun, 01 Oct 2000 10:06:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39D76F0A.77472051@stomp.stomp.tokyo>

Cameron Elliott wrote:

 
*laughs*

Gonna nurse this one for all it's worth, are you?


> Can someone tell me which is better to use?

Anyone who unequivocally states,

"This is better than that."
"That is better than this."
"This and That are better than That and This."

regarding Perl, is person who doesn't know
diddly squat about Perl and is full of my
favorite expression, mule manure.

There are no 'good', 'better' and 'best' for
all circumstances. It is up to you to decide
which is most appropriate for your script needs.


> I cant see the point of a hash except to store something 
> by reference to a name which is possible to do through 
> creative uses of arrays anyway.

This term "hash" which as I say, is fancy dog food for humans.
Inventing this expression, is right up there near top for my
"Idiotic Geekster Garbage" list. 

Array
Associative Array
Anonymous Array
Anonymous Associative Array
Array of Associative Arrays

 ..ad nauseam

Mix and match, they make sense, especially
from a mathematical point of view. Clearly,
computer science is a sub-field of mathematics.
In a final analysis, from data to hardware,
you are dealing with numbers, purely.

Hash does not make sense and leads to a lot
of confusion and misunderstanding. Hash is
best served to your old man when you are
pissed at him for whatever. Dog food.

Take look at today's postings. A person rattles
on about a hash and, in his displayed print out,
shows a simply array, not a hash.

 
> Can someone please correct me if I am wrong (which is probable) 
> and inform me of the advantages/disadvantages of each.

This is one of many beauties of programming, regardless
of language. Each whatever, has an advantage and has a
disadvantage. Only true advantage and disadvantage, is
your relative intellectual capacity. Most here within
this group, are working with a disadvantage.

 
>  An array is faster to access isn't it?

Faster than what? Faster than a speeding bullet?


$data = "red:apple¦yellow:banana¦purple:plum";

@Data = qw (red:apple yellow:banana purple:plum);


Which format is always faster for accessing
key and value pairs?


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Mon, 2 Oct 2000 01:16:51 +0800
From: "Cameron Elliott" <celliot@tartarus.uwa.edu.au>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39d771ba$0$31966@echo-01.iinet.net.au>


Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
news:98KB5.60$D4.135467008@news.frii.net...


<snip>
| Keep in mind the Perl moto: TIMTOWTDI.  Sure you might implement
| a form of associative memory using arrays but why do it when Perl
| gives you that as a primitive data type.  Hashes are useful as a
| convenience when working with structured data.  Hashes are also
| useful for implementing lookup tables of various types. And when
| creating recursive data structures.

What is TIMTOWTDI?
<snip>




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

Date: Sun, 01 Oct 2000 10:29:13 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <mbudash-9DFD0B.10291301102000@news.pacbell.net>

In article <39d771ba$0$31966@echo-01.iinet.net.au>, "Cameron Elliott" 
<celliot@tartarus.uwa.edu.au> wrote:

> Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
> news:98KB5.60$D4.135467008@news.frii.net...
> 
> 
> <snip>
> | Keep in mind the Perl moto: TIMTOWTDI.  Sure you might implement
> | a form of associative memory using arrays but why do it when Perl
> | gives you that as a primitive data type.  Hashes are useful as a
> | convenience when working with structured data.  Hashes are also
> | useful for implementing lookup tables of various types. And when
> | creating recursive data structures.
> 
> What is TIMTOWTDI?
> <snip>
> 
> 

"there is more than one way to do it"
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Sun, 01 Oct 2000 17:30:09 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <BwKB5.63$D4.174846976@news.frii.net>

In article <39d771ba$0$31966@echo-01.iinet.net.au>,
Cameron Elliott <celliot@tartarus.uwa.edu.au> wrote:
>
>Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
>news:98KB5.60$D4.135467008@news.frii.net...
>
>
><snip>
>| Keep in mind the Perl moto: TIMTOWTDI.  Sure you might implement
>| a form of associative memory using arrays but why do it when Perl
>| gives you that as a primitive data type.  Hashes are useful as a
>| convenience when working with structured data.  Hashes are also
>| useful for implementing lookup tables of various types. And when
>| creating recursive data structures.
>
>What is TIMTOWTDI?
><snip>
>

From http://userpage.fu-berlin.de/~corff/perl/perlkurs-5.html

    5. Programmierstil, oder TIMTOWTDI

    Eine der auf Neulinge gelegentlich abschreckend wirkenden
    Eigenschaften von Perl ist neben den kryptischen eingebauten
    Variablen die groe formale und syntaktische Freiheit in der
    Quellcodegestaltung. Diese Freiheit ermglicht es fortgeschrittenen
    Programmierern, erstaunlich kompakten Code zu schreiben. Auerdem
    fhren in Perl viele Wege zum Ziel. Dies ist in der Abkrzung
    TIMTOWTDI zusammengefat: There Is More Than One Way To Do It.
    Wie viele Wege es wirklich gibt, auch einfache Dinge in Perl
    auf berzeugende Weise zu komplizieren, wird in der JAPH-Sammlung
    dokumentiert. Die dortige Aufgabe ist, den Text Just Another
    Perl Hacker auszugeben. Die bizarrsten Ideen werden in einer
    eigenen Datei namens JAPH (Just Another Perl Hacker, zu finden
    auf CPAN:/misc/) gesammelt. Diese Sammlung eignet sich nicht
    nur zum Studium von Verfahren, die man besser nicht anwendet,
    sondern enthlt auch ein paar wirklich berzeugende Beispiele
    bestimmter Funktionen und Programmiertechniken.

Good luck
chris
-- 
    This space intentionally left blank


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

Date: Sun, 01 Oct 2000 10:34:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39D7759B.921202CA@stomp.stomp.tokyo>

Cameron Elliott wrote:

> What is TIMTOWTDI?

This Is Mentally 'Tarded Oh Wow That Dumb Idiot.

Heh!


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: 1 Oct 2000 12:49:12 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <8r7teo$97r$1@provolone.cs.utexas.edu>

In article <39d7648e$0$31974@echo-01.iinet.net.au>,
Cameron Elliott <celliot@tartarus.uwa.edu.au> wrote:
>Can someone tell me which is better to use?

Better for what?  It's hard to evaluate which tool is better if you
don't have some goal in mind for them.  Is a screwdriver better than a
hammer?  It depends on whether you need to work with screws or nails.
(Or philosophy, if you're a certain German philosopher from the latter
half of the 19th century.)

>I cant see the point of a hash except to store something by reference to a
>name which is possible to do through creative uses of arrays anyway.

It's possible to do that through creative uses of arrays.  It's also
possible to write the whole thing in assembly.  The question is which
is more convenient, and which solution fits the problem you're trying
to solve.

>Can someone please correct me if I am wrong (which is probable) and inform
>me of the advantages/disadvantages of each.

Associative arrays are better when you need to organize data in a way
that depends on some strings.  For instance, if your task is to scan a
text file and determine which words occur most frequently in the file,
you'd probably want to split the file up into words as you read it, and
then keep a running tally of how many times you've seen each word.

You could do this with a regular array, but you'd have to somehow
assign a number to each word and use that as an index to an array.  You
*could* do this, but it would be difficult.  If instead you can use
each word as the index to an associative array, the task will be much
easier.

>ps.  An array is faster to access isn't it?

If your task lends itself to storing data in an array, then it will
probably be faster.  But if not, you may spend lots of time trying to
compute indices for your array, and this might offset the gains
you achieved by avoiding the use of an associative array.

Also, one thing about Perl's implementation of associative arrays is
that the amount of storage required is approximately proportional to
the number of things stored in the array.  The storage size required
for regular arrays, though, is proportional to the highest numbered
index used.

So, if you do this following:

	$y = 1;
	for ($x = 1; $x < 30; $x++)
		{
		$hash{$y} = $x;
		$y *= 2;
		}

The storage used will be proportional to the number 30.  It'll probably
be less than a kilobyte.  But, if you do use a regular array instead:

	$y = 1;
	for ($x = 1; $x < 30; $x++)
		{
		$hash[$y] = $x;
		$y *= 2;
		}

then you'll probably run out of memory, unless you have a lot of it.

So, associative arrays can be good for storing sparse information, or
at least they can be better for them than regular arrays.

Hope that helps.

  - Logan


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

Date: 1 Oct 2000 06:42:24 -0700
From: James Vahn <jvahn@short.circuit.com>
Subject: Re: DBI and MS-Access
Message-Id: <8r7f00$ojq$1@short.circuit.com>

Jeff Zucker wrote:
> 	http://tlowery.hypermart.net/perl_dbi_dbd_faq.html

Thank you, much appreciated. The deja search turned up 745 messages
but I found none as helpful as this single line of yours. ;-)



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

Date: Sun, 01 Oct 2000 16:36:54 GMT
From: jim_marshall2268@hotmail.com
Subject: Re: File upload testing if it's there
Message-Id: <8r7p76$skc$1@nnrp1.deja.com>

You are correct, I made a typo when copying the text, it is an 'else'
not 'elif'


In article <7QsB5.1228$Q43.17691@news1.online.no>,
  =?iso-8859-1?Q?K=E5re_Olai_Lindbach?= <barbr-en@online.no> wrote:
>
> <jim_marshall2268@hotmail.com> skrev i melding
> news:8r5h0i$b27$1@nnrp1.deja.com...
> > The code I posted was a snippet from a larger perl script I wrote.
> The
> > code compiles and actually RUNS, what fatal error do you think
exists?
>
> Perhaps not fatal, but use of 'elif' instead of 'elsif' isn't perl.;-)
> You state you snipped it from the orginal.
>
> It will look upon elif as a method, and do both things!
>
> regards Mr Kåre Olai Lindbach.
>
> --
>
> Regards/mvh
> Olai - Mr. Kåre Olai Lindbach
> barbr-en@online.no
> http://barbr-en.home.online.no    (Norwegian/English)
> # NAPH, just perllover
> # Perl/Emacs(Viper)/Apache/MySQL
>
>


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


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

Date: Sun, 01 Oct 2000 16:39:30 GMT
From: yorktown5425@my-deja.com
Subject: Re: File upload testing if it's there
Message-Id: <8r7pc1$ssc$1@nnrp1.deja.com>

In article <39D6580D.E9A770AF@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
What a nice guy you are. Real helpful.  I'm so glad I tried to learn
perl and ask a question when I ran into trouble.

As for the code, it does exist and works - and no I'm not going to tell
such a nice person, such as yourself, where it is.

Again thanks for your insight and wisdom.
> jim_marshall2268@hotmail.com wrote:
>
> > Godzilla! wrote:
>
> > The code I posted was a snippet from a larger perl
> > script I wrote.  The code compiles and actually RUNS,
> > what fatal error do you think exists?
>
> I don't think your snippets are fatally flawed.
> I know they are fatally flawed. This is obvious
> with just a quick glance.
>
> Your code does not run. Actually, I am very
> skeptical this code of which you speak,
> even exists.
>
> Godzilla!
> --
> Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
> UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
> BumScrew, South of Egypt ¦ HTML Programming Class
>


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


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

Date: Sun, 1 Oct 2000 19:08:41 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: File upload testing if it's there
Message-Id: <Pine.GHP.4.21.0010011903320.2651-100000@hpplus03.cern.ch>

On Sun, 1 Oct 2000 jim_marshall2268@hotmail.com wrote:

> You are correct, I made a typo when copying the text, 

Don't do that.  Anyone who's going to give you worthwhile advice here
will expect you to copy/paste exactly the code you are referring to.

With any other procedure, the total amount of time and effort you're
going to waste is prodigious, and most of it won't be your own.  So
you'll quickly land in their killfiles, and be left to the tender
mercies of the trolls.

Of course your upside-down fullquoting is going to land you there too,
if you keep doing it.



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

Date: Sun, 01 Oct 2000 10:18:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: File upload testing if it's there
Message-Id: <39D771CA.3D6752AA@stomp.stomp.tokyo>

yorktown5425@my-deja.com wrote:

> Godzilla! wrote:


*laughs*

You used the wrong fake email address.


> What a nice guy you are. 

I am a gal.


> Real helpful.

Not for a lying sack of mule manure like you!


> I'm so glad I tried to learn perl and ask a 
> question when I ran into trouble.

Hopefully you have also learned I am not another
one these ignorant gullible fools populating this
inane newsgroup. You didn't run into trouble. You
ran into me! This is even worse.


> As for the code, it does exist and works - and no I'm 
> not going to tell such a nice person, such as yourself, 
> where it is.

Well hey! It's your lie. You can tell it anyway you want.


> Again thanks for your insight and wisdom.

My insight and wisdom are both, hard earned.
Why would I share my efforts with a cretin?


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Sun, 01 Oct 2000 13:14:31 GMT
From: jon_uk@my-deja.com
Subject: Files and things
Message-Id: <8r7dbl$ke6$1@nnrp1.deja.com>

Hi,

I have 2 small problems.  I need to -

- Find out what size (in bytes) a folder is.  Basicly, I need to know
the total size of /home/myname/cgi-bin (with the all the files etc).

- How do I copy everything in a folder, to another area.  This is for
backing up everything.  So I need to copy everything in /home/ to
something like /home2/.

Can anyone help?  I am on a Unix server if that helps.  Thanks,

Jon


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


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

Date: Sun, 01 Oct 2000 15:12:27 GMT
From: Maurizio Cimaschi <mauri@unixrulez.org>
Subject: Re: finding the structure of a hash
Message-Id: <avu6r8.cu.ln@HAL9000.jupiter.space>

Maurizio Cimaschi <mauri@unixrulez.org> wrote:
> print( map { "$grp_data => $grp_data{$_}\n" } keys %grp_data );

Err...

print( map { "$_ => $grp_data{$_}\n" } keys %grp_data );

-- 
Ciao, Maurizio.


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

Date: Sun, 01 Oct 2000 15:37:59 GMT
From: tmdryden@my-deja.com
Subject: Re: flocking while using the diamond operator?
Message-Id: <8r7lon$qa1$1@nnrp1.deja.com>

My problem is not with flock'ing- locking a file opened with "open"
works great.  The problem is when I use the <> diamond operator to open
the file- I do not know how to lock the file in that situation.  No one
addresses this situation anywhere in the perl newsgroups, either.


> >Try this:
> >
> > open FILE, 'file' or die "Cannot open the file: $!";
> >
> > flock FILE, LOCK_EX or die "Cannot lock the file: $!";
> >
> > while (<FILE>)
> > {
> > blah blah
> > }
>
> Did you try this?
>
>     $ touch file
>     $ cat flock_test
>     #!/usr/local/bin/perl -w
>     use strict;
>     open FILE, 'file' or die "Cannot open the file: $!";
>     flock FILE, LOCK_EX or die "Cannot lock the file: $!";
>     $ perl -c flock_test
>     Bareword "LOCK_EX" not allowed while "strict subs" in use at
> 	flock_test line 4.
>     flock_test had compilation errors.
>     $
>
> Or, even if we fix the compile problem:
>
>     $ cat flock_test
>     #!/usr/local/bin/perl -w
>     use strict;
>     use Fcntl ':flock';
>     open FILE, 'file' or die "Cannot open the file: $!";
>     flock FILE, LOCK_EX or die "Cannot lock the file: $!";
>     $ perl flock_test
>     Cannot lock the file: Bad file number at flock_test line 5.
>     $
>
> You cannot obtain an exclusive lock on a file that is not opened for
> updating.  You cannot obtain a shared lock on a file that *is* opened
> for updating.
>
> --
> Garry Williams
>


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


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

Date: Sun, 01 Oct 2000 16:37:52 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: flocking while using the diamond operator?
Message-Id: <ALJB5.114$b7.8485@eagle.america.net>

On Sun, 01 Oct 2000 15:37:59 GMT, tmdryden@my-deja.com
<tmdryden@my-deja.com> wrote:

>My problem is not with flock'ing- locking a file opened with "open"
>works great.  The problem is when I use the <> diamond operator to open
>the file- I do not know how to lock the file in that situation.  No one
>addresses this situation anywhere in the perl newsgroups, either.

You can't.  Process the @ARGV and open the file(s) explicitly.  

You probably should read the section on File Locking in the
perlopentut manual page.  

-- 
Garry Williams


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

Date: Sun, 1 Oct 2000 14:49:08 -0300
From: "Netcom" <aphowe@netcom.ca>
Subject: How to detect modules currently in use?
Message-Id: <cQKB5.13630$YG5.28282@tor-nn1.netcom.ca>

Is there any way to detect which are modules are currently in use at the
moment? The idea is to do the following:

# a module which the used has asked for (parsed out of a template)
$module = "CGI";

# get a list of modules which have already been imported via "use
ModuleName;"
@modulesCurrentlyInUse = ???

# import the module if it hasn't been already
use $module unless (grep { $_ eq $module } @modulesCurrentlyInUse);

Thanks,
kh






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

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


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