[17294] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4716 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 21:05:30 2000

Date: Tue, 24 Oct 2000 18:05:14 -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: <972435914-v9-i4716@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 24 Oct 2000     Volume: 9 Number: 4716

Today's topics:
    Re: A Simpler perlish way <MBalenger@worldnet.att.net>
    Re: A Simpler perlish way <MBalenger@worldnet.att.net>
    Re: Date Arithmetic - how???? <pauljohnston@cyberus.ca>
    Re: detecting client disconnect <jeff@vpservices.com>
    Re: File Locking and CGI <flavell@mail.cern.ch>
    Re: How do I do 'use $lib;' where $lib is a variable pa <ren.maddox@tivoli.com>
    Re: How do I do 'use $lib;' where $lib is a variable pa <jihad.battikha@sharewire.com>
    Re: How do I do 'use $lib;' where $lib is a variable pa (NP)
    Re: How do I do 'use $lib;' where $lib is a variable pa <ren.maddox@tivoli.com>
    Re: How do I do 'use $lib;' where $lib is a variable pa <lr@hpl.hp.com>
        How do I do 'use $lib;' where $lib is a variable packag <c.manley@chello.nl>
    Re: Legal email addresses... <nospam@david-steuber.com>
        Length of a string stored in a scalar <jeffahill@_ANTISPAM_.lucent.com>
    Re: Length of a string stored in a scalar (Jerome O'Neil)
    Re: local binmode? (Martien Verbruggen)
    Re: local binmode? <ren.maddox@tivoli.com>
        Net::Ping problems <drwho@xnet.com>
    Re: Object destructors not working properly? <MBalenger@worldnet.att.net>
    Re: Object destructors not working properly? <MBalenger@worldnet.att.net>
    Re: OT: Jihad definition <uri@sysarch.com>
    Re: OT: Jihad definition <jihad.battikha@sharewire.com>
        PageIndex <troyr@vicnet.net.au>
    Re: PageIndex <tony_curtis32@yahoo.com>
    Re: PageIndex <troyr@vicnet.net.au>
    Re: parse url <ianb@ot.com.au>
    Re: Perl with dBase files ("Ian.")
    Re: Regular expression help - redefinition of the probl <ianb@ot.com.au>
        renaming local() (David Wall)
    Re: replacing known lines <uri@sysarch.com>
    Re: replacing known lines <uri@sysarch.com>
    Re: replacing known lines <MBalenger@worldnet.att.net>
    Re: simple counter in a text file <workmonster2@home.com>
        use strict; with eval:: error messages to stderr <bbrown@addtoit.com>
    Re: What will the code look like? <themoriman@ntlworld.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Oct 2000 00:11:34 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: A Simpler perlish way
Message-Id: <WypJ5.5140$MR3.276254@bgtnsc04-news.ops.worldnet.att.net>

>  "$yday is the day of the year, in the range `1..365' (or `1..366' in leap
> years.)"
> Unfortunately, it is also incorrect.

Accuracy vs. precision?

:-)





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

Date: Wed, 25 Oct 2000 00:11:34 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: A Simpler perlish way
Message-Id: <WypJ5.5141$MR3.274646@bgtnsc04-news.ops.worldnet.att.net>

> >  "$yday is the day of the year, in the range `1..365' (or `1..366' in
leap
> > years.)"
> > Unfortunately, it is also incorrect.
>
> Before posting a similar response, I downloaded the latest 5.6.0 version
> (build 618) from ActiveState, and found that the error has already been
> corrected.

I'm assuming that the documentation was changed to reflect the code, not
vice versa.  Right?


--
Mike Balenger
    MBalenger@att.net   (or MichaelRunningWolf@att.net)
    (732)809-3613   cell

        All mammals learn by playing.





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

Date: Tue, 24 Oct 2000 22:17:27 GMT
From: Paul Johnston <pauljohnston@cyberus.ca>
Subject: Re: Date Arithmetic - how????
Message-Id: <39F60B2D.64603033@cyberus.ca>


HAAAAAAAHAAAAAAA!!!

Mark Wright wrote:

> One joyful day (18 Oct 2000 15:20:19 +0100 to be precise), Edward Avis
> <epa98@doc.ic.ac.uk> decided that the Usenet community would benefit
> from this remarkable comment:
>
> >I recommend Date::Manip.  It does everything you'd want to do with
> >dates.
>
> And I bet it's a lot cheaper too.
>
> Mark Wright
> - mark@giallo.demon.nl
> --
> perl -e "print join' '=>map{$_ if s/(\w*)(.)ay/\U$2\E$1/}grep/^\w/=>reverse qw+ackerhay :o( erlpay :o| notheraay :o\ ustjay :o)+"



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

Date: Tue, 24 Oct 2000 17:05:22 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: detecting client disconnect
Message-Id: <39F623C2.B4B58CD5@vpservices.com>

wkm2a@my-deja.com wrote:
> 
> I have $| = 1 so there shouldn't be any buffering....will it work if I
> just do a print "" and exit on failure?

$| eliminates the buffering in your Perl script.  It has no impact on
the possible buffering on your web server, the possible buffering on a
client's proxy server, the possible buffering on a client's browser each
of which can potentially eliminate any gain that $| bought you.  

-- 
Jeff


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

Date: Wed, 25 Oct 2000 00:02:38 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: File Locking and CGI
Message-Id: <Pine.GHP.4.21.0010242354380.14078-100000@hpplus03.cern.ch>

On Tue, 24 Oct 2000, Darren Dunham wrote:

> You need to lock on a much smaller/shorter/faster granularity.

Agreed

> Have the first process lock the file, get the info, unlock the file.
> Then, when the from comes back, lock the file, update the info, unlock
> the file. 

In general that may not be enough.  What if another instance went in
and updated the file before you got around to updating it?  If you
aren't holding the lock throughout, then you need some kind of
recovery or rollback procedure to deal with this eventuality.

> You don't need persistant locks because you don't want persistant locks.

You certainly want to avoid persistent locks, but not to the point of
negating the benefit of the lock by casually allowing an update
between fetching data and updating it.  So if you need to do those
separately in two independent invocation steps, then you got to make
provisions for dealing with the consequences.

good luck



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

Date: 24 Oct 2000 17:37:54 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read  from a file?
Message-Id: <m37l6x50hp.fsf@dhcp11-177.support.tivoli.com>

Jihad Battikha <jihad.battikha@sharewire.com> writes:

> Craig Manley wrote:
> 
> > my $lib = 'foo'; # Value of $lib is actually read from file.
> > use $lib;
> 
> eval "use $lib";

You likely already know this, but I'll point out for Craig's benefit
that this solution will not work for his problem as $bar would be
imported too late (unless declared with "use vars qw($bar)" or the
like, but that is probably not desirable).

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 24 Oct 2000 18:35:52 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read  from a file?
Message-Id: <39F60EC8.37D71C5D@sharewire.com>

Craig Manley wrote:

> my $lib = 'foo'; # Value of $lib is actually read from file.
> use $lib;

eval "use $lib";

You should also check for error conditions...

There are better ways to do this, but, maybe you should read some more
on "use", "packages", "modules", and "eval", since the final solution
depends on the context of what you're trying to do.

-- 
Jihad Battikha <jihad.battikha@sharewire.com>
  Sharewire, Inc. --- http://www.sharewire.com/
    - Free forms, programs, and content for web sites.
    - No assembly required.

Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html




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

Date: Tue, 24 Oct 2000 22:46:30 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read from  a file?
Message-Id: <ajoJ5.51156$Ly1.570920@news5.giganews.com>

c.manley@chello.nl wrote:
: 
: use strict;
: 
: my $lib = 'foo'; # Value of $lib is actually read from file.
: use $lib;

If I understand your question correctly, you can do:

my $lib = "CGI";
eval "use $lib"; die("error: $@") if $@;

-- 
Nate II


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

Date: 24 Oct 2000 17:31:45 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read from  a file?
Message-Id: <m3bsw950ry.fsf@dhcp11-177.support.tivoli.com>

Craig Manley <c.manley@chello.nl> writes:

> Well here's my problem in a simplified example:
> 
> #!/usr/bin/perl -w
> #
> 
> use strict;
> 
> my $lib = 'foo'; # Value of $lib is actually read from file.
> use $lib;
> 
> print $bar; # $bar is always exported by $lib.

The problem is that "use" happens at compile time, before $lib is
set.  You can get around this with a BEGIN block which, in your case,
will need to read from the file and set $lib.  Something like:

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

my $lib;

BEGIN {
  # code to set $lib goes here
}

use $lib;

print $bar;
__END__


Don't put the "use" statement inside the BEGIN block, as you will then
have the same problem, just sooner.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 24 Oct 2000 16:08:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do I do 'use $lib;' where $lib is a variable package name read from  a file?
Message-Id: <MPG.145fb647705e7f4798ae6a@nntp.hpl.hp.com>

In article <ajoJ5.51156$Ly1.570920@news5.giganews.com> on Tue, 24 Oct 
2000 22:46:30 GMT, NP <nvp@spamnothanks.speakeasy.org> says...
> c.manley@chello.nl wrote:
> : 
> : use strict;
> : 
> : my $lib = 'foo'; # Value of $lib is actually read from file.
> : use $lib;
> 
> If I understand your question correctly, you can do:
> 
> my $lib = "CGI";
> eval "use $lib"; die("error: $@") if $@;

But that happens during execution, which is too late to be useful in 
compiling the remainder of the file.  Better to put everything 
(including the reading of $lib from the file) into a BEGIN { } block.

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


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

Date: Tue, 24 Oct 2000 22:29:34 GMT
From: Craig Manley <c.manley@chello.nl>
Subject: How do I do 'use $lib;' where $lib is a variable package name read from  a file?
Message-Id: <39F60F21.C1CC8A6A@chello.nl>

Well here's my problem in a simplified example:

#!/usr/bin/perl -w
#

use strict;

my $lib = 'foo'; # Value of $lib is actually read from file.
use $lib;

print $bar; # $bar is always exported by $lib.

-Craig Manley.


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

Date: Tue, 24 Oct 2000 22:47:51 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Legal email addresses...
Message-Id: <m37l6xkga2.fsf@solo.david-steuber.com>

tony@svanstrom.com (Tony L. Svanstrom) writes:

' Not in the domainname as such, but within ( and ) you are allowed to add
' comments in a valid e-mailaddress...
' 
' Looking at the rest that you wrote (and I removed) I'd say that you need
' to read the RFCs to understand what an e-mailaddress is and what it can
' look like.

You are right.

I imagine the simplist way to verify the e-mail address might look
something like this (error checks omitted):

my $mh = new Net::SMTP('mailhost');
$mh->mail('webserver@foo.com');
$mh->to($email_address_to_validate);
$mh->data();
$mh->datasend("To: $email_address_to_validate\n");
$mh->datasend("From: webserver@foo.com\n");
$mh->datasend("Subject: Verify your e-mail address\n\n");
 ...
$mh->dataend();
$mh->quit();

Where the ellipses would be the body of a message with a URL to go to
to verify that the e-mail account is valid.  If the e-mail is bogus,
then an error should occur in the call to to().  Either that, or the
mail will be bounced.

This curtesy of perldoc Net::SMTP.

I would do other things on a web page.  I would database the e-mail
address to prevent it from being entered multiple times.  Don't want
the site to be used to mailbomb someone.  I would have a mail account
to catch the bounced messages so that they can be kept track off.
Bounces may happen quickly enough to return an error page in a CGI or
mod_perl script.

-- 
David Steuber | Perl apprentice.  The axe did not stop the
NRA Member    | mops and buckets from flooding my home.
ICQ# 91465842
***         http://www.david-steuber.com/          ***


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

Date: Tue, 24 Oct 2000 18:38:18 -0500
From: Jeff H <jeffahill@_ANTISPAM_.lucent.com>
Subject: Length of a string stored in a scalar
Message-Id: <39F61D6A.59CB4D3D@_ANTISPAM_.lucent.com>

This may seem like a stupid question, but how do I determine the length of a
string stored in a scalar?  I've read the perldoc on Perl data types, but it
didn't seem to tell how to do this.  It would be incredibly handy information to
have in some of my applications.  

Also, does Perl store a scalar string as in other languages, such as a Sting in
C++ or Java?  Or does it have it's own internal representation?  This is more
for my own edification, and not necessarily important that it get answered.

Thanks.


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

Date: Tue, 24 Oct 2000 23:56:25 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Length of a string stored in a scalar
Message-Id: <JkpJ5.1338$Ee3.108547@news.uswest.net>

Jeff H <jeffahill@_ANTISPAM_.lucent.com> elucidates:
> This may seem like a stupid question, but how do I determine the length of a
> string stored in a scalar?  I've read the perldoc on Perl data types, but it
> didn't seem to tell how to do this.  It would be incredibly handy information to
> have in some of my applications.

The 'length' function, oddly enough, might do what you want.

Read about length, and other handy functions in the perlfunc document distributed
with your Perl instalation.

perldoc -f length
perldoc perlfunc


-- 
"Civilization rests on two things: the discovery that fermentation 
produces alcohol, and the voluntary ability to inhibit defecation.  
And I put it to you, where would this splendid civilization be without 
both?" --Robertson Davies "The Rebel Angels" 


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

Date: Tue, 24 Oct 2000 22:09:30 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: local binmode?
Message-Id: <slrn8vc24m.a0g.mgjv@verbruggen.comdyn.com.au>

On Tue, 24 Oct 2000 18:21:18 GMT,
	Bart Lateur <bart.lateur@skynet.be> wrote:
> Gwyn Judd wrote:
> 
> >Why the heck would you want to do something like that? Either a file is
> >binary or it isn't. WHat's the point of switching half way through?
> 
> For example Postscript files can contain both text parts and pure binary
> parts.

But, as Craig Berry pointed out to me a little while ago in private
correspondence, it is not formally correct to call binmode after any
I/O is done on the filehandle. it may work for you, but it shouldn't.

# perldoc -f binmode
[snip]
    binmode() should be called after open() but before
    any I/O is done on the filehandle.
[snip]

This was in the context of a CGI program producing binary (PNG)
image data on STDOUT. I called binmode after the headers, but before
the first print [1]. On a unix system this doesn't make any difference,
but on others it may, and even on a unix system it could, depending on
what happens behind the scenes.

If you need to write 'mixed' data, then you are writing binary data.
If you need line endings to be correct in a file like this, you'll
have to do it yourself. Fortunately, PostScript line endings are
flexible.

Martien

[1] For anyone wondering: I was using the CGI module and its header()
method. It is perfectly safe to call binmode before that call, because
CGI always uses a correct line ending, and not simply "\n". See the
CGI.pm module. Another reason not to handroll CGI related code.
-- 
Martien Verbruggen              | 
Interactive Media Division      | 42.6% of statistics is made up on the
Commercial Dynamics Pty. Ltd.   | spot.
NSW, Australia                  | 


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

Date: 24 Oct 2000 17:14:08 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: local binmode?
Message-Id: <m3g0ll51lb.fsf@dhcp11-177.support.tivoli.com>

Michael Carman <mjcarman@home.com> writes:

> Taking a SWAG[1] at what you're after, I think you want to duplicate
> STDOUT using another (probably local) filehandle and then binmode()
> that, because you can't undo binmode().

Actually, you can undo binmode...

$ perldoc -f binmode

       binmode FILEHANDLE, DISCIPLINE

       binmode FILEHANDLE
               Arranges for FILEHANDLE to be read or written in
               "binary" or "text" mode on systems where the run-
               time libraries distinguish between binary and text
               files.  If FILEHANDLE is an expression, the value
               is taken as the name of the filehandle.
               DISCIPLINE can be either of `":raw"' for binary
               mode or `":crlf"' for "text" mode.  If the
               DISCIPLINE is omitted, it defaults to `":raw"'.
 ...

On the other hand, I haven't tested this, so I suppose that you might
not be able to switch back and forth, but that would seem silly.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 24 Oct 2000 17:08:56 -0500
From: Michael Maxwell <drwho@xnet.com>
Subject: Net::Ping problems
Message-Id: <vr74s21q4cn.fsf@typhoon.xnet.com>

Please refer to the code listing below:

What I'm trying to do is create a simple perl script to test network
connectivity on a list of hosts.  I thought that using Net::Ping's
pingecho() function would be a good start.  However, this program only
functions correctly for the FIRST host listed in the "netping.hosts"
file, but all the others report incorrect results.

The netping.hosts file is just a listing of hostnames, one per line:

host1
host2
host3
etc...

What am I missing or doing wrong here?

#!/usr/bin/perl -w
use strict;
use Net::Ping;
use vars qw($hostname $timeout);

$timeout=2;

open(HOSTS, "netping.hosts") or
        die "Cannot open netping.hosts: $!";

while (<HOSTS>) {
        chomp;
        next if ($_ =~ /^$/);

        unless (pingecho($_, $timeout)) {
                print "Host \"$_\" is down.\n";
        }
}


-- 
Fight email spam:  http://www.cauce.org/



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

Date: Tue, 24 Oct 2000 23:16:13 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: Object destructors not working properly?
Message-Id: <1LoJ5.8377$xJ4.275453@bgtnsc06-news.ops.worldnet.att.net>


>
> When running perl test.pl I get the following output:

What's in test.pl?


--
Mike Balenger
    MBalenger@att.net   (or MichaelRunningWolf@att.net)
    (732)809-3613   cell
    (321)799-4087   copper (FL)

        All mammals learn by playing.





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

Date: Wed, 25 Oct 2000 00:06:31 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: Object destructors not working properly?
Message-Id: <bupJ5.5137$MR3.273766@bgtnsc04-news.ops.worldnet.att.net>

I had a problem relating to garbage collection (GC).  Maybe you can
benefit from the hours I spent tracking it down.

Summary: There are two levels of GC.  The first one runs during the
program.  The second one runs after exit to get whatever the first one
couldn't get.  I was seeing the effects of this.

*Most* discussions of GC deal with the first phase: objects get GC'd
when the reference count goes to zero.  This is typical at end of
scope, usually at a closing brace.  My problem dealt with the second
phase: what happens after a program exits, but before the process
exits?

What?

Here's a simple example from "Programming Perl", Section 5.3.9 - A
Note on Garbage Collection.

{               # make $a point to itself
    my $a;
    $a = \$a;
}


The reference count to $a never goes to zero, even outside of the
block.  It will not be GC'd during the lifetime of the program.  It
will get GC'd during the second phase.  This insight was the key to
solving my problem.

This section contained the answer to my problem.  Unfortunately, I
hadn't yet formulated my question in the correct form to get the
answer from this section.  Seems that a good question leads to a good
answer.  A bad question leads to confusion.  (e.g. Have you stopped
beating your spouse yet?)

My original question was: Why don't my contained objects get GC'd
*after* the container?

It seemed to me that the contained objects would be referenced by the
container.  Therefore, the container would have to get GC'd first,
releasing the references to the contained objects, which would then
get GC'd.  I *should* be able to place a freeze operation in the
container's DESTROY method.

My observation was different.  The freeze operation was noticing that some
of the contained objects had already been GC'd.

Placing "goodbye" messages in each destructor showed a (seemingly)
random order of destruction between containers and contained objects.

Then I placed a "goodbye" message before the exit.

Viola.  I noticed that all the GC happened after exit.  After exit?

My better question became:  Why are all my objects getting GC'd after exit?

That had a better answer: Because the containing object was actually
contained by another object.  I had created a module level cache to
speed up subsequent lookups.  The cache was held in a file scoped
hash.  That hash referenced my containers.  Because the cache had a
lifetime of the entire process, it didn't get GC'd during the process.
It's lifetime was the key here.  The scope was limited, but the
lifetime was not.  Anything referenced by that cache had its reference
count stay non-zero for the duration of the process.  After exit, the
GC mechanism doesn't give a rats ass what order it uses.  It assumes
that the program would have done whatever it wanted to do before it
exited.

Fair enough.  Obscure at the time, but fair enough.  Now that the GC's
not random, I can work with it.

Solution: Kill the things on *my* time, during the process.  That's a
simple undef in an END block.  Once I undef'd the cache, the
containers could be GC'd, then the contianed objects were GC'd.  Just
how I wanted.

Lesson: Beware of unanticipated references.  They prevent GC a the
"obvious" end of scope time.


Cross-lesson: There's a thread on subroutine references that's
probably got the same kinds of issues.

I've found that drawing pictures on white boards helps a lot.


Here's the comments I pulled directly from that module.


# ================================================================
# Declare an object cache to be used by new().

use vars qw(%_cache);

END {
    # The cache *must* get garbage-collected while the program is
    # active.  Allowing GC to happen after exit() leaves the order up
    # to chance -- contained and referenced objects can be GC'd before
    # the container, preventing the freeze from capturing the entire
    # hierarchy.

    # In short -- undef here makes sure that the garbage collection
    # order is predictable.
    undef %_cache;  # Very necessary!!!
}

BEGIN {
    %_cache = ();  # Not strictly necessary.
}





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

Date: Tue, 24 Oct 2000 22:07:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: OT: Jihad definition
Message-Id: <x74s21optv.fsf@home.sysarch.com>


jihad,

here it is for you. it started with ou resident troll, moronzilla, not
wishing to address you by your given name and on top of it she insulted
by with an incorrect translations/expansion. ignore her as most of us do
here. we just followup to clean up affter her code droppings. then joe
kline posted a stupid followup (the quoted text below) and the new
thread got started.

<context>
i think moronzilla knows as much perl as hitler.
</context>

that should end this thread. and hopefully end moronzilla as well. go
away.

uri

"Godzilla!" wrote:
> 
> Jihad Battikha wrote:
> 
> > "Godzilla!" wrote:
> > > Jihad Battikha wrote:
> > > (Battikha has the same problem with no attributes)
> 
> > Why are you addressing me by my last name and in the third person?
> 
> It causes me concern to address you in an active
> first person voice and address you by your given
> name, which is,
> 
> "Muslim Fanatic Holy War"
> 
> Many people would consider this name of yours
> as a metaphor meaning "a terrorist". Muslim
> terrorists, any nationality of terrorists, are
> not high on my list of popular people. Fanatics
> are a type of people whom raise my level of concern.

Enlightened folk would defer to the larger meaning of jihad - striving
or determined effort (I've heard it defined as "the struggle").

A lucid article about the meaning of jihad is at:

http://www.ict.org.il/articles/jihad.htm

I tend to think of jihad in general to mean the struggle to come to
grips with one's faith (in Allah in this case) and to spread that
faith. While there are many references to jihad in an armed sense, the
context determines the intention/meaning.

Given that the Arab world gave us algebra, preserved/advanced
chemistry, and preserved a lot of the Greek texts, I tend to defer to
the benefits the Moors had. Of course, there are plenty in the Muslim
world that preach violence.


-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 24 Oct 2000 18:32:17 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: OT: Jihad definition
Message-Id: <39F60DF1.46852F6A@sharewire.com>

Uri Guttman wrote:

> here it is for you. it started with ou resident troll, moronzilla...

Thanks for the quoted posts, Uri - I guess my "Godzilla!" killfile entry
might have trampled on more of the thread then I would have thought. :-)

And to address moronzilla directly: I find that racism goes hand-in-hand
with stupidity.  Thanks for re-inforcing that.  Don't bother
responding.  You're already in my killfile.  In fact, I don't even know
why you responded with your ignorant/racist spew in the first place
since it was clear I had already killfiled you.  Dolt.

-- 
Jihad Battikha <jihad.battikha@sharewire.com>
  Sharewire, Inc. --- http://www.sharewire.com/
    - Free forms, programs, and content for web sites.
    - No assembly required.

Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html




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

Date: Wed, 25 Oct 2000 10:58:59 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: PageIndex
Message-Id: <MnpJ5.6469$SF5.130101@ozemail.com.au>

Does anyone know of a module i can use like HTML::PageIndex or one which has
the same features for a Debian Linux box?


Thanks in Advance


----------------------------------------------------------------------------
------------------
Tr
----------------------------------------------------------------------------
----------------




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

Date: 24 Oct 2000 19:04:58 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: PageIndex
Message-Id: <87bsw9rdjp.fsf@limey.hpcc.uh.edu>

>> On Wed, 25 Oct 2000 10:58:59 +1100,
>> "Troy Rasiah" <troyr@vicnet.net.au> said:

> Does anyone know of a module i can use like
> HTML::PageIndex or one which has the same features for a
> Debian Linux box?

How about using HTML::PageIndex ?  (Hint: why on earth
wouldn't it work on your machine too?)

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Wed, 25 Oct 2000 11:29:49 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Re: PageIndex
Message-Id: <JQpJ5.6486$SF5.130642@ozemail.com.au>

> > Does anyone know of a module i can use like
> > HTML::PageIndex or one which has the same features for a
> > Debian Linux box?
>
> How about using HTML::PageIndex ?  (Hint: why on earth
> wouldn't it work on your machine too?)

Sys admin didn't want me downloading modules from CPAN....

and i couldn't find it doing a dselect...and i have done dpkg --update

and it can't find it..so maybe i'm missing something heh




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

Date: Wed, 25 Oct 2000 10:14:55 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: parse url
Message-Id: <39F617EF.461D5EE2@ot.com.au>

Gus wrote:

> PTMTOWTDI, this works fairly well.
>
> ($scheme,undef,$host,@rest) = split('/',$url);
> ($path,$query) = split('\?',join('/',@rest));
>
> print
>     "Host: $host\n",
>     "Path: $path\n",
>     "QS: $query\n";

I might suggest a few improvements:

 . Splitting on multiple forward slashes would be more readable (no need for
undef), but might be slower. I haven't benchmarked it, but I doubt there's
much in it.

 . Using the LIMIT argument to split avoids the need for a join later.

#!/usr/bin/perl -w

use strict;
use vars (qw($url $scheme $host $rest $path $query));


$url = "http://www.hello.there/path?query_string";

($scheme, $host, $rest) = split('//?', $url, 3);
($path, $query) = split('\?', $rest);

print
    "Host: $host\n",
    "Path: $path\n",
    "QS: $query\n";

__END__


Regards,


Ian




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

Date: Wed, 25 Oct 2000 00:22:09 +0000 (UTC)
From: ian.freedomnet@softhome.net ("Ian.")
Subject: Re: Perl with dBase files
Message-Id: <20001025.0022.1252snz@softhome.net>

     jeff@vpservices.com "Jeff Zucker" wrote:
JZ> 
JZ> The DBD::XBase driver for the Perl DBI (database interface) can read and
JZ> write dbase III+ files.  See:
JZ> 
JZ>    http://www.symbolstone.org/technology/perl/DBI/

Thanks very much, Ill have a look.

-- 
Bye now,
        Ian.


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

Date: Wed, 25 Oct 2000 08:25:10 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: Regular expression help - redefinition of the problem
Message-Id: <39F5FE36.407E0326@ot.com.au>

jsfinn@my-deja.com wrote:

> After pounding my head for several days, I found a (simple, but
> extremely verbose) way of doing it:
>
> password=^(
> (\d[a-zA-Z]|[a-zA-Z]\d)\w{4,8}|
> \w(\d[a-zA-Z]|[a-zA-Z]\d)\w{3,7}|
> \w{2}(\d[a-zA-Z]|[a-zA-Z]\d)\w{2,6}|
> \w{3}(\d[a-zA-Z]|[a-zA-Z]\d)\w{1,5}|
> \w{4}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,4}|
> \w{5}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,3}|
> \w{6}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,2}|
> \w{7}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,1}|
> \w{8}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0}
> )$
>
> The original problem was that I was having an "AND" problem
> like saying
>
> $pass =~ /\w{6,10}/ && $pass =~/(\d[a-zA-Z]|[a-zA-Z])/
>
> because I'm not actually writing the code.... just the regular
> expression.
>
> Anyone have a more elegant way of doing this?

Sorry for the command-line grossness. I'm in a hurry.

perl -e '@a = qw(xyzzygy2k short sh77 OK_except punc-t +other3 1234567
123456y y12345678); foreach (@a) {print "Matched $_\n" if
/^(?=.*\d)(?=.*[^\W\d_])[^\W_]{6,10}$/;}'

Regards,


Ian




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

Date: Mon, 23 Oct 2000 16:23:41 -0400
From: darkon@one.net (David Wall)
Subject: renaming local()
Message-Id: <8FD6AA45Cdarkononenet@206.112.192.118>

[crossposted to clp.moderated and clp.misc]

I just finished reading Larry Wall's speech at 
http://archive.develooper.com/perl6-meta@perl.org/msg00427.html.  In it, he 
mentions the possibility of renaming local() (in the paragraph beginning 
'Rename the local operator?'). If you'll listen to a suggestion from 
someone who knows nothing about Perl internals, then what about renaming it 
to 'this'?  

Larry said, q{
It'll often be used with an our() declaration.  It depends on whether it 
should come before or after the our() keyword.  If it came after, you'd say 
"our temporary $foo = 2", but if it came before, you'd say "temporarily our 
$foo = 2".
}

If you put it before, then you could say "this our $foo = 2", that is, 
"this copy of our $foo is 2".

Just a thought....

-- 
David Wall
darkon@one.net


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

Date: Tue, 24 Oct 2000 22:11:37 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: replacing known lines
Message-Id: <x7zojtnb3a.fsf@home.sysarch.com>

>>>>> "WvdB" == Walter van den Berg <vandenb@NO.SPAMcistron.nl> writes:

  WvdB> Found it. *blush*

  WvdB> I will read the perlfaq better.
  WvdB> I will read the perlfaq better.
  WvdB> I will read the perlfaq better.
  WvdB> I will read the perlfaq better.

if only other newbies would behave like this. :)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 24 Oct 2000 22:13:41 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: replacing known lines
Message-Id: <x7wvexnazu.fsf@home.sysarch.com>

>>>>> "WvdB" == Walter van den Berg <vandenb@NO.SPAMcistron.nl> writes:


  WvdB> Mm - I'm not sure if I should say this here, but I used an
  WvdB> example that was in "perl for dummies". And the capitalized var
  WvdB> was there.  No flames please! - I later bought "learning perl"
  WvdB> from O'Reilly.

instead of us flaming you, you should flame that book. dummies makes for
great fire starting or it can be used to prop up a table or desk. the
content is a waste of good printer's ink.

learning perl is worth keeping to actually READ!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 24 Oct 2000 23:06:09 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: replacing known lines
Message-Id: <BBoJ5.8370$xJ4.275098@bgtnsc06-news.ops.worldnet.att.net>

>>   print OUT
'<OD:FO:"'."$Name".'",bitmap,"afbeeldingen/'."$Name".'">'."\n";

> That is very hard to read, not least because of the superfluous quotes
> around simple scalar variables.  Compare this:
>
>     print OUT qq{<OD:FO:"$Name",bitmap,"afbeeldingen/$Name">\n};

My style-guide $0.02 --

    I somtimes revert to printf when things get hairy to read.  It's
probably a few more CPU cycles, but I find it easier to separate the *how*
(via the format string) from the *what* (via the argument list).  A
high-level scan tells me that I'm pretty-printing the same variable twice.
A middle-level scan shows that I'm printing them as strings by seeing the
two %s formatters.  I rarely need to do a low-level scan of the format
string once I've written (and tested) the code.

     printf OUT qq{<OD:FO:"%s",bitmap,"afbeeldingen/%s">\n},
            $Name, $Name;

P.S.  Nice use of qq.  Don't you love that you don't have to double quote
the quotes?  I really like this operator.


--
Mike Balenger
    MBalenger@att.net   (or MichaelRunningWolf@att.net)
    (732)809-3613   cell
    (321)799-4087   copper (FL)

        All mammals learn by playing.





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

Date: Wed, 25 Oct 2000 00:25:21 GMT
From: "kbent" <workmonster2@home.com>
Subject: Re: simple counter in a text file
Message-Id: <RLpJ5.513014$8u4.6508704@news1.rdc1.bc.home.com>

Thanks, Jihad - I'll be giving your suggestions a try tomorrow.  They look
excellent.
Regards,

Kev
"Jihad Battikha" <jihad.battikha@sharewire.com> wrote in message
news:39F60646.9136B9BE@sharewire.com...
> kbent wrote:
>
> > I've fumbled with the following script a bit, but no real success
> > ....
> > open (BAG, "file.txt"); #supposed to open the file handle BAG and
> >   link it to a text file.
>
> That's fine, but you should also check for error condistions if the file
> didn't open.
>
> open (BAG, "file.txt") || die $!;
>
> $! will contain the error string.  Since your script is for a CGI
> environment, you might want to encapsulate the error in another
> subroutine.  Anyway, you're using the CGI module so let's ignore that
> issue for now...
>
> > $contents=(BAG);  #supposed to put the contents of BAG into a variable
>
> That's not going to work. Try:
>
> $contents = <BAG>;
>
> That will suck in the first "line" of the ASCII text file assuming your
> record separator global ($/) is set to "\n".  If you want to suck in a
> mult-line file all into one variable, you would do something similar to:
>
> open (BAG, "file.txt") || die $!;
> my $contents;
> {
>   local $/;
>   $contents = <BAG>;
> }
> close(BAG);
>
> or, you could avoid playing with $/ and use a temporary array:
>
> open (BAG, "file.txt") || die $!;
> my @contents = (<BAG>);
> my $contents = join('', @contents);
> close(BAG);
>
> > print "$contents\n\n";  #just checking what's in the file
> > ($contents=++$contents); #increments the contents of the variable
>
> Simpler:
> $contents++;
> (equiv. to $contents = $contents + 1)
>
> > ....
> > print (BAG $contents); #supposed to write the new
> >   incrementation to the file
>
> No, you opened the file with an implied *read* so printing to it will
> fail.  You must first close the file and then re-open it to do an
> explicit write.  Example:
>
> close(BAG);
> open(BAG, ">file.txt") || die $!;
>
> Then you can print to the file.  Everything else in the file will get
> wiped out so you may want to open it for simultaneous read/write.  Read
> the Perl docs on how to do that.
>
> > print h1($watch);  #a final print of the contents.
>
> You're not checking to see if your file write actually worked - all
> you're doing is printing a variable you changed, not the success of the
> write.  All you're going to see is the same number over-and-over, no
> matter how many times you reload the page.
>
> > close BOX;
>
> Where did that handle come from?  You didn't declare it earlier with a
> proper discriptor...
>
> Also, you should look into file locking whenever you're eading from or
> writing to a potentially shared file like a hit counter database.
>
> --
> Jihad Battikha <jihad.battikha@sharewire.com>
>   Sharewire, Inc. --- http://www.sharewire.com/
>     - Free forms, programs, and content for web sites.
>     - No assembly required.
>
> Disclaimer:
> Before sending me commercial e-mail, the sender must first agree
> to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html
>
>




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

Date: Tue, 24 Oct 2000 20:06:10 -0400
From: William Lewis Brown <bbrown@addtoit.com>
Subject: use strict; with eval:: error messages to stderr
Message-Id: <39F623F2.2A9486A3@addtoit.com>

Hi,
	I am using eval to compile and run code at runtime.  Due to the nature of my
environment, this code may at times be incorrect.  I do the standard thing and
check $@ after an eval to see if the code compiled and ran successfully.  I
always run with "use strict" and so the code that I am evaling is subject to the
"use strict" rules.
	Unfortunately, it seems as if any errors associated with "use strict" are spit
out on stderr and do not appear as part of $@.  The error messages I do get in
$@ are often very cryptic due to the code not passing the "use strict;" tests.
	What is the best way for me to work around this problem?  It would be ideal if
I could get my "use strict;" errors placed in a variable.
	Thanks in advance for your help.

					Bill
-- 
William L. Brown
Email: bbrown@addtoit.com


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

Date: Tue, 24 Oct 2000 23:59:11 +0100
From: "The Moriman" <themoriman@ntlworld.com>
Subject: Re: What will the code look like?
Message-Id: <MtoJ5.11578$Rk5.265695@news2-win.server.ntlworld.com>


Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8vbt81.956.tadmc@magna.metronet.com...
>
> Errr, I thought he meant me, for not knowing who Spike was...
>

Possibly, I was thinking it was my mis-attribution. Maybe it was only for
everyone;O)




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

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


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