[11040] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4640 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 13 09:07:11 1999

Date: Wed, 13 Jan 99 06:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 13 Jan 1999     Volume: 8 Number: 4640

Today's topics:
    Re: "Email this page to a friend" script <pdcawley@bofh.org.uk>
    Re: A really easy string question kjer@my-dejanews.com
    Re: A really easy string question kjell.ericson@sth.frontec.se
    Re: Array problem <aspinelli@ismes.it>
    Re: associative arrays (hashes) dave@mag-sol.com
    Re: cgi/perl fuming meltdown dave@mag-sol.com
    Re: CONCLUSIVE PROOF:  John is dead though (Bry)
    Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus <wschmidt@tyler.net>
    Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus <no@spam.here>
    Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus <no@spam.here>
        Copyright license of modules shipped with Perl <hniksic@srce.hr>
        DBM performance guideline anyone please? <simsi_NO_SPAM@hotmail.com>
        dbmmanage and Perl (Questions about dbfiles)... (Thomas Klinger)
    Re: Displaying and entering data for drop down boxs <simsi_NO_SPAM@hotmail.com>
        Help needed with locking info@gadnet.com
        Jpeg or Gif filesize leading@technologist.com
        logging hits remotely <michael@processing.net>
    Re: logging hits remotely <cw@dwc.ch>
    Re: Perl Controlling Server RS-232 Port <spamsux-tex@habit.com>
    Re: Perl Criticism <rra@stanford.edu>
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: SUMMARY: Optimizing `eval' in a loop <hniksic@srce.hr>
    Re: tied hashed hash looses item #1 <mymail@nospam.com>
    Re: Using require command (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 13 Jan 1999 11:41:29 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: "Email this page to a friend" script
Message-Id: <s7pg19fpfh2.fsf@windrush.elsevier.co.uk>

usenet@schulte.org (Christopher Schulte) writes:

[... Tale of spammer related woe deleted ...]

> SPAMMERS must die.  I wonder if I should report this to the RBL?  What
> do you think?

I think it has (fsck all)^0.5 to do with Perl.

-- 
Piers


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

Date: Wed, 13 Jan 1999 11:05:28 GMT
From: kjer@my-dejanews.com
Subject: Re: A really easy string question
Message-Id: <77hull$dvn$1@nnrp1.dejanews.com>

In article <369ba4f0.9065131@news.newsguy.com>,
  info@gadnet.com wrote:
> I have a variable ($variable) which contains:
> $pathname = "/path-of-indeterminate-length/myfile.txt";
> I want to end up with a variable that contains:
> myfile.txt

This is a good solution that split a string into path and filename:

$_=$pathname;
m/^(.*)([^\/]*)$/;
print "path is: '$1', filename is '$2'\n";

  // Kjell Ericson

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 13 Jan 1999 12:14:47 GMT
From: kjell.ericson@sth.frontec.se
Subject: Re: A really easy string question
Message-Id: <77i2ni$h02$1@nnrp1.dejanews.com>

In article <369c9d50.72569268@news.newsguy.com>,
  info@gadnet.com wrote:
> I think I've cracked it:
> $variable =~ /\"(.*)\"\;$/;
> seems to work.

$_=$pathname;
m/^(.*\/)([^\/]*)$/ || m/^()(.*)$/;
$path=$1;
$filename=$2;

Another real solution.
The \" has nothing to do with the filename anyway.

 // Kjell

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 13 Jan 1999 12:13:10 +0100
From: Andrea Spinelli <aspinelli@ismes.it>
Subject: Re: Array problem
Message-Id: <369C7FC6.8C393DCD@ismes.it>

Rafiq Mateen wrote:
> 
> I have two arrays I need to combine together examples below.
> 
> @one:
> 
> here we are now at
> one two  three four
> it is time to go
> five six seven eight
> 
> @two:
> 
> 1654 just go no
> jordan retired wow
> now what is up
> 56 19200 net of the
> 
> They are both single dimensional arrays
> 
> I need them to look like this when combined:
> 
> here we are now at  1654 just go no
> one two  three four jordan retired wow
> it is time to go    now what is up
> five six seven eight 56 19200 net of the
> 
> HELP!!!!!!

I think that

my @three = map( $one[$_] . $two[$_], 0 .. $#one );
will solve the problem.

Any Perl wizard with a better solution?

Hope this helps
  Andrea


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

Date: Wed, 13 Jan 1999 09:58:26 GMT
From: dave@mag-sol.com
Subject: Re: associative arrays (hashes)
Message-Id: <77hqo0$asc$1@nnrp1.dejanews.com>

In article <77gs7m$grn$1@nnrp1.dejanews.com>,
  bluepuma@mailexcite.com wrote:
> Hi there,
>
> I want to use an associative array with IP addresses as index.
>
> $ip1="123.456.123.456";
> $ip2="123.123.123.123";
>
> %no=();
> $no[$ip1]=1;
> $no[$ip2]++;
> print $no[$ip1];
>
> But it results in "2", cause perl only takes the first number
> of the IP address as index. How can I change that ?

You need to research the difference between arrays and associative arrays (or
'hashes' as they're generally called in these parts).

You're using arrays. The index of an array must be an integer, therefore Perl
is helpfully converting your string into an integer.

If you really used hashed (as you claim you are) then the key can be any
scalar value and your IP strings would be fine.

hth,

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 13 Jan 1999 10:04:21 GMT
From: dave@mag-sol.com
Subject: Re: cgi/perl fuming meltdown
Message-Id: <77hr31$b71$1@nnrp1.dejanews.com>

In article <mCXm2.4060$H3.424@news1.atlantic.net>,
  "Christopher Gross" <elephant@atlantic.net> wrote:
> Ok, i admit defeat! (temporarily)
> Heres the script:
>
> #!c:\perl\bin
> $|=1;
> $mypic[0]="/bannerimages/test/banner1.gif";
> $mypic[1]="/bannerimages/test/banner2.gif";
> $mypic[2]="/bannerimages/test/banner3.gif";
> $mypic[3]="/bannerimages/test/banner1.gif";
> srand(time ^ $$);
> $pick = rand(@mypic);
> print "Content-type: image/gif\n\n";
> open (BANNER,$mypic[$pick]);
> print <BANNER> ;
> close (BANNER);
>
> Heres the call:
>
> <IMG SRC="/cgi/banner.pl" WIDTH=400 HEIGHT=40 BORDER=0>
>
> Perl location is supposedly corect, path to the banners is correct but it
> dosn't work! Can anybody point me in the right direction?  Please???

"Doesn't work" is a pretty vague description. It's going to be difficult to
give you any help from that. What happens (or doesn't happen)?

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 13 Jan 1999 12:53:24 GMT
From: bry@NOSPAM.mnsinc.com (Bry)
Subject: Re: CONCLUSIVE PROOF:  John is dead though
Message-Id: <369c9729.12224759@news.mnsinc.com>

Recently, eric <eendersnospam@ford.com> wrote:

>John Lennon said so,  so there!

But now he is dead! A pity really. He was a nice guy!



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

Date: Wed, 13 Jan 1999 06:54:20 -0600
From: WWS <wschmidt@tyler.net>
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <369C977C.25D4A95B@tyler.net>


eric wrote:
> 
> John Lennon said so,  so there!

BANG, BANG, BANG, BANG! That's what he gets for saying he's
bigger than Jesus.  Although the holes were rather small, 
they had to count them all. - Deacon

peep


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

Date: Wed, 13 Jan 1999 07:16:22 -0600
From: "JLenn" <no@spam.here>
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <77i6ao$gt1$1@usenet46.supernews.com>

LOL!!

He's right you know........ :)

eric wrote in message <369C51A8.6872@ford.com>...
>John Lennon said so,  so there!




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

Date: Wed, 13 Jan 1999 07:21:08 -0600
From: "JLenn" <no@spam.here>
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <77i6jm$h29$1@usenet46.supernews.com>

Yeah.......I'm sure Jesus would have aproved of a fanatical Christian (MC)
shooting John Lennon for saying he was bigger than Jesus. No....MC will rot
in HELL for what he did....and John Lennon will be singing in Heaven for all
of the good things he did for humanity. If there even are such places
(Heaven and Hell).

WWS wrote in message <369C977C.25D4A95B@tyler.net>...
>
>eric wrote:
>>
>> John Lennon said so,  so there!
>
>BANG, BANG, BANG, BANG! That's what he gets for saying he's
>bigger than Jesus.  Although the holes were rather small,
>they had to count them all. - Deacon
>
>peep




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

Date: 13 Jan 1999 11:06:55 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Copyright license of modules shipped with Perl
Message-Id: <kign23n32rk.fsf@jagor.srce.hr>

According to the Perl documentation, all of Perl should be under both
the GPL and the Artistic license.  However, not all the modules seem
to make that clear.  For instance, Getopt::Long says:

    ################ Copyright ################

    # This program is Copyright 1990,1997 by Johan Vromans.
    # This program is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License
    # as published by the Free Software Foundation; either version 2
    # of the License, or (at your option) any later version.
    # 
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    # 
    # If you do not have a copy of the GNU General Public License write to
    # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
    # MA 02139, USA.

This does not seem to allow the use of Artistic license for that
module, and work derived from it (the word ``artistic'' isn't
mentioned anywhere in the .pm file.)

Is the Artistic/GLP symbiosis valid for the whole of Perl, or only the 
"Perl proper", the distributed modules being on their own?


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

Date: Mon, 11 Jan 1999 17:57:47 -0000
From: "Simmo" <simsi_NO_SPAM@hotmail.com>
Subject: DBM performance guideline anyone please?
Message-Id: <jV0n2.4$c72.72@news.enterprise.net>

Hi,

Would anyone suggest a point at which you say "no" to text-based db files
and move to a 'real' database package? I want to create a simple search
system for up to 500 requests per hr with a max of 6000 records longterm
(1000 bytes per record)....should i be considering a package or will i be
ok? I could split the db into 4 parts potentially but would prefer to avoid
if poss. Hopefull, you'll just say its a 'bandwidth thang' :)

Many thanks to those who can assist :)

Ian Sims
simsi@hotmail.com







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

Date: Wed, 13 Jan 1999 11:25:45 GMT
From: t.klinger@mobilkom.at (Thomas Klinger)
Subject: dbmmanage and Perl (Questions about dbfiles)...
Message-Id: <369c80da.11998762@194.48.138.240>

Hi there! 
Dropped a little the desperation. :)

My problem as follows:
I generated a dbfile with the dbmmanage-function comming with the
apache-module mod_auth_dbm.
With dbmmanage myfile view I can see all users with their decrypted
password.
So I tried to open this dbfile in Perl using this code:

#!/usr/bin/perl
use AnyDBM_File;
tie (%USER,"NDBM_File","myfile",O_RDWRIO_CREAT,0666);
while (($name,$passwd)=each(%USER)){
	print "User $name has password $passwd\n";
	# also tried print "$name -> $passwd\n";
}
untie (%USER);

But nothing happens. Either the method is wrong or I'm using the wrong
DBM Format.
Can anyone tell me which DBM-Format dbmmanage is using?
Further, how do I decrypt those passwords in Perl? Is it possible?

Thanks to all in forward and to all in the past who where giving me
power to continue learning Perl.


Kind regards

       Thomas Klinger
       Systemspecialist
=======================================
t.klinger@mobilkom.at
http://www.mobilkom.at
=======================================





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

Date: Mon, 11 Jan 1999 17:59:57 -0000
From: "Simmo" <simsi_NO_SPAM@hotmail.com>
Subject: Re: Displaying and entering data for drop down boxs
Message-Id: <kV0n2.5$c72.72@news.enterprise.net>


Alan Copeland <hotdogboy@Icdc.com> wrote in message
77beop$92d$1@remarQ.com...

I have a file with the names of book genres, sepereatae by commas
>(e.g. comedy,young adult,fiction)  Then I wanted a function to read these
>and put them in a drop down box for selection.


Ian Sims replied:

I dont claim to be an expert but i achieved it without problems as below -
putting the info in a string and then using print to print the string at the
end of the loop. I tend to use pipes ( | ) as my field delimiters - (could
be there's a comma getting in the way ?). Dont know if this helps but there
you go anyway - works for me  :)

$catlinks = "<select name=whatever>";
open (SUBLINKDB, "index_sublinks.txt");
while (<SUBLINKDB>)
{
  $items = "$_";
  @fields = split (/\|/, $items);
  $category   = $fields[0];
  $subcategory   = $fields[1];
  $title     = $fields[2];
  $unused    = $fields[3];
  $linkname     = $fields[4];
  $target_frame  = $fields[5];
$allow_user_links = $fields[6];
$allow_user_links =~ s/\n//g;

  $catlinks .= "<option
value=\"$category-$title\">$category-$_title</option>\n";

   }
   close (SUBLINKDB);
$catlinks .= "</select>";


Ian Sims
simsi@hotmail.com








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

Date: Wed, 13 Jan 1999 16:41:03 GMT
From: info@gadnet.com
Subject: Help needed with locking
Message-Id: <369ccb87.84384761@news.newsguy.com>

I am writing a freeware script for distribution over the web. I'm
fairly new to perl and would like some advice on file locking. I need
a foolproof file lock/unlock routine which will work on the widest
variety of unix platforms. Should I be using flock, semctl, fcntl,
some home made semaphore locking or some combination of these
approaches?

Drummond Miles


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

Date: Wed, 13 Jan 1999 21:57:29 +0800
From: leading@technologist.com
Subject: Jpeg or Gif filesize
Message-Id: <MPG.11072728a667932989691@news.singnet.com.sg>

How can I know the file size of a gif or jpeg like (lengthxwidth)?


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

Date: 13 Jan 1999 12:08:44 GMT
From: "Michael R. Harper" <michael@processing.net>
Subject: logging hits remotely
Message-Id: <369C8C56.A6AC05DC@processing.net>

Perl/Web Experts,

I have a basic web account that allows no CGI access (just a
form-to-email and a simple counter).  I would like to get stats on who
is visiting that site.  Is there a way to run the cgi from another
server and log hits on the basic site?  Please send me any ideas you may
have, whether backed up by code or not.

Sincerely,

Michael R. Harper
michael@processing.net
http://www.processing.net



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

Date: Wed, 13 Jan 1999 13:58:07 +0100
From: Christoph Wernli <cw@dwc.ch>
To: "Michael R. Harper" <michael@processing.net>
Subject: Re: logging hits remotely
Message-Id: <369C985A.2D25E62E@dwc.ch>

"Michael R. Harper" wrote:
> 
> I have a basic web account that allows no CGI access (just a
> form-to-email and a simple counter).  I would like to get stats on who
> is visiting that site.  Is there a way to run the cgi from another
> server and log hits on the basic site?  Please send me any ideas you may
> have, whether backed up by code or not.

The only chance I see is to get hold of the logfiles and process them -
on another machine, that is.

Cheers,

-w


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

Date: Wed, 13 Jan 1999 02:41:03 +0000
From: Austin Schutz <spamsux-tex@habit.com>
Subject: Re: Perl Controlling Server RS-232 Port
Message-Id: <369C07BF.8DC@habit.com>

Steve Shawl wrote:
> 
> Hello
> Is there a perl command or set of commands that will allow a script to
> output a single character to the rs-232 port of the server that the
> script is running on?
> Thank you (in advance)
> Steve Shawl


`echo -en "$ARGV[0]" > $ARGV[1]`

	Though perhaps that's not what you had in mind. Your question is rather
vague.

	Austin


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

Date: 13 Jan 1999 02:25:01 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl Criticism
Message-Id: <yl1zkz5v2a.fsf@windlord.stanford.edu>

topmind <topmind@technologist.com> writes:
> Russ Allbery <rra@stanford.edu> wrote:

>> That's not what I'm saying.  What I'm saying is that given an
>> experienced programmer, it really doesn't matter that much, and given
>> inexperienced programmers, it's noise lost in the other things that
>> will be problematic.

> Lack of experience is not what I am fussing about. It is those who take
> shortcuts at the expense of others or the longer term integrity of the
> system.

Which is something that one learns not to do with experience.  Sure, there
are some experienced programmers who still aren't very good programmers,
but most people learn with time.

Taking shortcuts that hurt code maintainability is bad programming.  If
one is plagued by bad programming, one should hire good programmers;
changing the programming language is likely, in my opinion, to still leave
you with the same problem.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 13 Jan 1999 10:55:42 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn79oute.34e.dformosa@godzilla.zeta.org.au>

In article <77hhu6$2sb$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:

[...]

>Lack of experience is not what I am fussing about. It is those
>who take shortcuts at the expense of others or the longer term
>integrity of the system.

I've writion very short scripts whos lifetime is only as long as they
remained in my history file.  They purly existed to get one job done
and only that job, now given these have no long term intergaty why
should I write them in such a way?


-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 13 Jan 1999 12:24:07 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn79p437.34e.dformosa@godzilla.zeta.org.au>

In article <77himo$3en$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
>In article <369ABB34.16E5B504@mediaone.net>,
>  "Michael D. Schleif" <mds-resource@mediaone.net> wrote:

[...]

>> Many of us here who have participated in this thread are living better
>> today than ever -- and Perl, the status quo and its dialectic,
>> evolutionary path, has contributed to that.
>
>Are you judging Perl by its ability to project your job by
>being too hard for a new programmer to figure out?

No he is not, he is judging it by how much it improves his life.  If
it makes my life better, makes me and outhers happy then I think it is
good.

Its not anything about spagetty code, its about writing what I think
and it working.  All programing langs should alow my to put my thourts
down on paper.



-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 13 Jan 1999 12:30:54 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn79p4fu.34e.dformosa@godzilla.zeta.org.au>

In article <77hjkh$490$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
[...]

>Think like a manager. They do not want to risk being stuck with
>cryptic code that takes the follow-on guy or guydette 1 hour
>per line to reverse engineer.

Then they enforce code review.

>Suppose you owned a business where a programmer spent 4 years
>building all the software. The programmer suddendly quits
>and you hire a new Perl expert. The Perl expert inspects the
>code and realize that the system is composed of 30,000 lines
>of code that looks something like this:

What I've found is often its not the code thats crptyic, but a
combernation of a cryptic bussness model and poor design.



-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 13 Jan 1999 12:38:10 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn79p4ti.34e.dformosa@godzilla.zeta.org.au>

In article <77hkaq$4oe$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
>In article <slrn79lors.fmt.sholden@pgrad.cs.usyd.edu.au>,
>  sholden@cs.usyd.edu.au wrote:
[...]

>> It's called a code-review... But you won't care so why am I bothering.
>
>
>Few companies actually spend the money or time for such.

Then thats there fault, code review is the only truly effective method
of ensuring good code.  If the maniger cares about readable code then
will spend the time.

[...]

>> Well take the latest source and produce a patch that does just that and
>> see if it works. This is how open source is meant to work. Freedom and all
>> that. 'Show me the code' is the cry when people just talk about the things
>> they think would be wonderful.
>
>I am not sure I follow. What do you mean by "patch"?

Patch is a utility writtion by Mr Wall, given a large body of code you
run patch with a short amount of code containing the diffrences
between the base code and your new upgrade and its applied before compiling.

[...]

>> I actually look forward to seeing your new project to create a better perl.
>> I just doubt you actually want to do any more than talk about your ideas,
>> as evidenced by the details required for implementation missing from your
>> web pages.
>>
>
>I am not skilled at building interpreters.

Then find someone how is and shears your views and then them to build it.

[...]

>Why do some see this as the litmus test for language ideas?

Because it proves that your idears work or fail.

>I don't get it. (Other's say the litmus test is reading
>100 academic books.)

Becomeing well read would allow you to express your idears better and
understand deeper the costs and benifits.


-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 13 Jan 1999 12:51:23 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn79p5mc.34e.dformosa@godzilla.zeta.org.au>

In article <77hl76$6jt$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
>In article <slrn79lvjs.mtj.dformosa@godzilla.zeta.org.au>,
>  dformosa@zeta.org.au (David Formosa (aka ? the Platypus)) wrote:

[...]

>> Given that I've never had need for such a keyword, and given that the
>> need to use such a keyword would indercate realy poor design and given
>> that a number of alternative better scheams exist, do you think adding
>> it is worth it?
>
>
>What do you mean it would "indercate poor design"? Better schemes?
>Could you please elaborate? I don't think you understand what
>"isolate" is all about. C is ALL "isolate", Perl is none (excluding
>packages).
>It allows chosing which routines acts like C and which act like Perl.

Now I understand what you are talking about.  Your talking about
Dynamic vs Static scoping.   The "C" style is called static scoping,
perl also has static scoping as well, if you use "my" to declare the
verabiles instead of "local".

Note the diffrence between these two progames

$x=1;
&a;
print $x;

sub a {
  my $x=10;
  &b;
}

sub b {
  $x=$x+1;
}

Returns 2 because b added one to the global $x

$x=1;
&a;
print $x;

sub a {
  local $x=10;
  &b;
}

sub b {
  $x=$x+1;
}

Returns 1 because b added one to the $x it inhereted from a.[1]

[...]

>> No its not natural because I'm used to it, its natural because it
>> mirrors the way I think.  I can often guess at a perl construct to do
>> what I wish to do and have it work because perl has been well designed.
>>
>
>Well, I think in terms of tables and table-oriented operations,
>and Perl is not very table-oriented IMO. (It can be bent to
>do it, but bent is bent.)

Then write a module to do manipulate it into the way you like.

[...]

>> >Is it and add-on, yes or no?
>>
>> DBM support is as much an add on as the regexp engion, hash table
>> support, its socket support or its abilit to do mathimatics.
>>
>
>
>I don't beleive that regex's need "use" statements and knowledge
>of which directory it's in.

dbmopen was in perl before use statemets where.



[1] Yes I know this is not strictly true, but its works.

-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 13 Jan 1999 12:55:16 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: SUMMARY: Optimizing `eval' in a loop
Message-Id: <kig4spve6aj.fsf@jagor.srce.hr>

mcafee@waits.facilities.med.umich.edu (Sean McAfee) writes:

> In article <kigr9t0e13b.fsf@jagor.srce.hr>,
> Hrvoje Niksic  <hniksic@srce.hr> wrote:
> >Thanks to everyone who replied; as proposed by most people, I now use
> >this:
> 
> >$closure = eval "sub { $expr }"
> >  || die "Error while compiling code: $expr\n";
>    ^^
> This is probably better written as "or".

The production code looks like this:

    defined ($compiled_closure = eval "sub { no strict; $expr }")
      || die "Error compiling \`$expr': $@";

> >loop {
> >  ...
> >  eval { &$closure; } || die "Error while evaluating code: $expr\n";
> >  ...
> >}
> >(Of course, the second eval is merely to trap runtime errors.)
> 
> There's a bug here (besides the obvious one that "loop { }" is
> actually a seldom-used method-dispatch syntax, most likely not what
> you intended).

Actually, it was an attempt at pseudo-code.  The actual code is a
foreach() loop.

> The result of eval { } is the value of the last expression
> evaluated, so if your $closure subroutine happens to return a false
> value, your script will die.  Use $@ to check on the success of
> eval:
> 
> eval { &$closure };
> die "Error while evaluating code: $expr\n" if $@;

You are right, thanks (in fact, the actual code was checking whether
eval {} was defined(), but that's also wrong, given that the
subroutine can return undef.).  I'm now using this:

	  eval { &$compiled_closure };
	  die "Error evaluating \`$expr': $@" if $@;

BTW, where is the correct place to announce my extra-super-mega-useful 
utility to the world, once it's finished (ha!)?  Should I fire away to 
comp.lang.perl.announce, or should I first try here for some review?


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

Date: Wed, 13 Jan 1999 08:19:29 -0500
From: JPAH-FLA <mymail@nospam.com>
Subject: Re: tied hashed hash looses item #1
Message-Id: <369C9D61.1A8E99DF@nospam.com>

Thank-You for the insight. I reviewed the CPAN docs on "storable" & I plan to
investiage it further today.

I also had another idea- why not just make the first hash element a
throw-away, like

   $h{tom}{one}="whocares?";

since all of the other references came back fine? Would that be reliable, or
perhaps I'm just lucky that the other tied elements came back without errors?
Repeatedly I only seemed to loose element 1.

That seems like it might be a lot easier than a whole new storage mechanism.

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

Eric Bohlman wrote:

> JPAH-FLA <mymail@nospam.com> wrote:
> : I'm finding that an anon hashed hash tied with dbmopen consistently
> : looses the fist item of each hash. I've demonstrated it in W32 as well
> : as unix. I couldn't find any reference to this issue in Camel or this
> : newsgroup or websites, but not for lack of trying!
>
> : I created a hashed hash similar to the example in camel 2nd Ed P 270. It
> : worked fine:
>
> :   $h{tom}{ctype} = "cat";  $h{tom}{colour} = "brown"; $h{tom}{build} =
> : "fat";
>
> There's your problem.  A "hash of hashes" or "two-dimensional hash" is
> actually implemented as a hash of references to hashes.  The problem is
> that when you store it in a DBM file, the references cease to refer to
> anything when they're read back.  You have to somehow "serialize" your
> hash values before storing them.  Modules like Data::Dumper and Storable
> will help.  Also check out the chapter on persistence in _Advanced Perl
> Programming_.



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

Date: Wed, 13 Jan 1999 10:23:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Using require command
Message-Id: <369d67cc.6529868@news.skynet.be>

Peter Morrow wrote:

>The require info in the documentation seems to have little correlation to
>what I'm trying to do. I think what I'm trying is too basic.
>Firstly which file must return true?

You seem to miss the finer points of the syntax a bit.

You must understand that the distinction between "statement" and
"expression" is very thin in Perl. Therefore, 

	1;

all by itself is a valid statement.

If you "require" a file, the contents of the file are read and executed
(using something very closely related to "eval"; "do FILE" is somewhere
in between). The net result is that sub declarations are added to the
dictionary, and any bare code is executed, usually for initialisation.
Thus, it is not just "compiled" as in traditional compiled languages. It
is "run".

Now, if you simply eval a string containing a bunch of Perl statements,
it's the result of the last one actually run that gets remembered. Try:

	$code = 'if ($_) { "true"; } else { "false"; }'; # string
	print "$code\n";
	foreach (0,1) {
		print " $_ -> ",eval $code, "\n";
	}

Result:
	if ($_) { "true"; } else { "false"; }
	 0 -> false
	 1 -> true

(a string is an expression, and thus, it is a statement too).

Now, YOU, the programmer of the library file, are free to indicate if
all initialisation in it went well. That's what the "true" value in the
end is for: if all is well, then a statement returning a true value
should be executed last. Therefore, "1;" is usually the last statement
in the file.

   HTH,
   Bart.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 4640
**************************************

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