[17371] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4793 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 2 14:06:15 2000

Date: Thu, 2 Nov 2000 11:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973191914-v9-i4793@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 2 Nov 2000     Volume: 9 Number: 4793

Today's topics:
    Re: + or - <jeff@yoak.com>
    Re: @ARGV and Absolute URL (Tad McClellan)
    Re: @ARGV and Absolute URL (BUCK NAKED1)
        Again problems executing Perl scripts in a shell <spamming@teleline.es>
    Re: backtick question NEWBIE (Tad McClellan)
        Beginner help with code <michael.segulja@sgi-lsi.com>
    Re: Beginner help with code <latsharj@my-deja.com>
    Re: Compiling Perl 5.6 with ming 32 <fingerslip@yahoo.com>
        Double fork trick: why does grandkid avoid becoming a z <ljnelson@unix.amherst.edu>
    Re: Double fork trick: why does grandkid avoid becoming <josef.moellers@fujitsu-siemens.com>
    Re: embedded variables in a file (Tad McClellan)
    Re: embedded variables in a file <tzz@heechee.beld.net>
        garbage collecting hashes are slow <fulko@wecan.com>
        gnupg/pgp blues? (Crypt::PGP, et al.) (Ulrich G. Wortmann)
    Re: how to make a read from a socket non-blocking (Tom Christiansen)
    Re: i'm in 'use vars' hell (Mark-Jason Dominus)
    Re: i'm in 'use vars' hell <bart.lateur@skynet.be>
        Is there a way to get all PID's within Perl ? msalerno@my-deja.com
    Re: Keeping a List of Objects (Tom Christiansen)
    Re: Keeping a List of Objects <jeffp@crusoe.net>
    Re: Keeping a List of Objects (Tom Christiansen)
        killfiles (was Re: Perl style and module searches) (Tad McClellan)
    Re: Need suggestions on optimization <newspost@coppit.org>
        Newbie:  How to COMPARE DATES in Perl??? <clarityassoc@earthlink.net>
    Re: Newbie:  How to COMPARE DATES in Perl??? (Clay Irving)
        Pattern Matching /isg bluearchtop@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 02 Nov 2000 10:02:12 +0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: + or -
Message-Id: <8tsa8p0q55@news1.newsguy.com>

In article <973025006.410086@hpvablab.cup.hp.com>, "Richard J. Rauenzahn"
<nospam@hairball.cup.hp.com> wrote:

> "Jeff Yoak" <jeff@yoak.com> writes:

>>I think both of these suggestions are really silly and better
>>suggestions are found elsewhere in this thread, but what runtime error
>>message do you receive and with what version of Perl?  That statement
>>won't generate a runtime error message with any perl I remember, which
>>stretches back to 4.036 . Did you actually try it?
> 
> I just did -- did you try it with '-w'?

OK... it generates a warning, not a runtime error.  That's somewhat of an
important distinction.  Depending on the source of the data, testing the
numeric value of something like "toto" may be either surprising or
unsurprising, but we shouldn't overly panic people that things are going explode
on them for trying something like that.  Issueing a warning is probably
the right amount of panic.  :-)

Cheers,
Jeff


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

Date: Thu, 2 Nov 2000 07:16:01 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: @ARGV and Absolute URL
Message-Id: <slrn902mo1.dst.tadmc@magna.metronet.com>

On Thu, 2 Nov 2000 01:49:07 -0600 (CST), BUCK NAKED1 
   <dennis100@webtv.net> wrote:

>What does $ARGV[0] store anyway?


Perl's special variable are described in the perlvar std doc:

   perldoc perlvar


@ARGV stores what the description there says it stores  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 2 Nov 2000 11:59:38 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: @ARGV and Absolute URL
Message-Id: <20114-3A01AB8A-63@storefull-243.iap.bryant.webtv.net>

Thanks Tad. I obviously need to learn about @ARGV, $ARGV and $ARGV[0]. I
don't know why they are used, or how to use them. I thought $ARGV was
just a filename or scalar, but I'm obviously wrong because something
like

$ARGV = getstore("http.webhost.com", $file) 

doesn't work. Do you put $file in getstore(as above), OR should $file be
replaced withthe absolute URL where the file is to be kept for
reading??? I've read perltutopen, and didn't find much there. I'll read
the doc you suggested. 

It'd be great though, if someone could tell me how to read in the
contents of an absolute URL that's not on my server with $ARGV[0], for
processing. :)

Regards,
Dennis



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

Date: Thu, 02 Nov 2000 19:06:34 +0100
From: PiLoT <spamming@teleline.es>
Subject: Again problems executing Perl scripts in a shell
Message-Id: <3A01AD2A.F079A8E3@teleline.es>

Hi all!

Sorry, but this is my real e-mail address.

I've made a perl script and I can only execute in that way:
$ perl script_name.pl

I put the 'x' permission to the perl and the header of the script
contain:
#!/usr/bin/perl
and I've checked that perl is in that directory.

I want to execute the script with
$ ./script_name.pl
How can I do that???
Thanks a lot.

If you could reply to the mail too.









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

Date: Thu, 2 Nov 2000 07:20:34 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: backtick question NEWBIE
Message-Id: <slrn902n0i.dst.tadmc@magna.metronet.com>

On 2 Nov 2000 04:52:06 -0500, Jason Goodrow <goodrow@panix.com> wrote:
>A shell call that works from command line but not from cgi input


Perl FAQ, part 9:

   "My CGI script runs from the command line but not the browser.
    (500 Server Error)"


>#!/usr/local/bin/perl5


You should enable warnings and the "use strict" pragma:

#!/usr/local/bin/perl5 -w
use strict;


>$status = `./otherprog $width`;
            ^^


Is 'otherprog' in your current directory?

Do you know what current directory your CGI programs are given?

Either chdir() to the right directory or use absolute paths.


>(this may be a more ...authoring.cgi question  but ... I don't know (very confused))


You are right. Your question is off-topic here.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 02 Nov 2000 15:32:13 GMT
From: Michael Segulja <michael.segulja@sgi-lsi.com>
Subject: Beginner help with code
Message-Id: <8ts1dt$6qv$1@nnrp1.deja.com>

I am writing a perl script that takes a specific directory and reads in
all of the MP3 files in that directory and enters the tag information
into a database.  I have this working with 105 separate artists so
far.  I have a second script called queryArtist.cgi that will query on
artist and return the output to a web page.  I'm trying to do it as
simple as possible, so for now I simply click a link on the web page
called ARTIST, which runs the CGI script.  The code for the script is
below.  Here's what I am trying to do:

I query the main table (mp3main) on artist.  This returns a list of all
the artists if I print this out to STDOUT.  However, they are listed
multiple times, so I then want to take those artists and insert them
into a temporary table with a UNIQUE INDEX so duplicates will not be
inserted.  Then I will run a query on the temporary table and send that
output to the web page.  It is partly working because I get my
AUTO_INCREMENT artistid field up to 105, which is correct for the
number of unique artists I have.  However, that artist column is empty,
and I don't know why.

Here's the code:
------------------------ Begin Perl Code ------------------------
#!/usr/bin/perl -w

use diagnostics;
use strict;
use CGI;
use DBI;

my $db = "mp3db";
my $host = "localhost";
my $user = "mp3";
my $password = "mp3pass";
my $statement = "SELECT artist FROM mp3main";
my @ary;
my $item;

# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
	$user, $password, {PrintError => 1, RaiseError => 1});

# Query table mp3main on artist.
my $ary_ref = $dbh->selectall_arrayref($statement);

foreach my $item(@$ary_ref) {
	push @ary, $item->[0];
	my $sth = $dbh->prepare("INSERT IGNORE INTO tmp_artists
(artist) VALUES
		(?)" ) || die "Cannot insert into table: $DBI::errstr";
	$sth->execute();
}

# Disconnect from the database.
$dbh->disconnect;
------------------------------- End Perl Code ------------------------
I have tried changing $sth->execute() to $sth->execute($item) as well
as $sth->execute(@ary).  I get something in the artist field, but it is
something like hash[0209d9cmi2kl] for each 105 artists.

I'm sure this is probably something simple, but I just don't know where
to look to find out what I'm doing wrong.  I've looked through perldoc
DBI, but I get more confused each time I find something new.  Most of
the code above I have found from examples on the Internet, and I have a
pretty good grasp of what I need to do, just not quite the right syntax.


I really appreciate any help I can get. I have learned an incredible
amount from this NG so far.

Thanks everybody!!

Michael


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


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

Date: Thu, 02 Nov 2000 17:24:51 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Beginner help with code
Message-Id: <8ts80o$d3g$1@nnrp1.deja.com>

In article <8ts1dt$6qv$1@nnrp1.deja.com>,
  Michael Segulja <michael.segulja@sgi-lsi.com> wrote:

> I query the main table (mp3main) on artist.  This returns a list of
> all the artists if I print this out to STDOUT.  However, they are
> listed multiple times, so I then want to take those artists and
> insert them into a temporary table with a UNIQUE INDEX so duplicates
> will not be inserted.

> my $statement = "SELECT artist FROM mp3main";
Try 'SELECT DISTINCT artist FROM mp3main'

--
Regards,
Dick


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


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

Date: Thu, 2 Nov 2000 10:23:37 -0800
From: "Abhishek Roy" <fingerslip@yahoo.com>
Subject: Re: Compiling Perl 5.6 with ming 32
Message-Id: <8tsbho$ooa$1@agate.berkeley.edu>

> Various FAQs around will also tell you that the command interpreter in
> Win9x is seriously broken and inform you that the prospects of ever
> getting Perl to build on Win9x are seriously dim.
 ...I
> One thing you could try if you cannot switch to a machine running NT to
> do this, is to install the NT command interpreter to your Win98 system,
> and then run the build / install in it. The command interpreter is
> named CMD.exe. On the Cygwin website there is documentation that
> contains this tip and there is/was a pointer to a URL at M$ for
> downloading a CMD.exe that will run on Win9x.

Thanks, I'll go look it up.
Abhishek





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

Date: Thu, 02 Nov 2000 16:12:49 GMT
From: Laird Nelson <ljnelson@unix.amherst.edu>
Subject: Double fork trick: why does grandkid avoid becoming a zombie?
Message-Id: <3A01927E.CAE3552A@unix.amherst.edu>

Referencing
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/fork.html, which
outlines the double-fork trick as follows:

    unless ($pid = fork) {
        unless (fork) {
            exec "what you really wanna do";
            die "no exec";
            # ... or ...
            ## (some_perl_code_here)
            exit 0;
        }
        exit 0;
    }
    waitpid($pid,0);

The grandchild of the original spawning process--the grandchild's path
of execution is inside the second "unless" block--apparently does not
become a zombie because its parent process ID somehow magically becomes
that of the init process.  My question is, how? why?  Nothing in fork(2)
that I can see (note: that I can see :-)) implies that a forked child's
child will somehow magically get assigned to the init process as a
child.

(The root question underlying all this is: what's the perl equivalent of
executing a command in the background?  setsid() looks like it might do
the trick, I guess, but I thought there was another way just using
fork().)

Cheers,
Laird

--
W: laird.nelson@time0.com / P: ljnelson@unix.amherst.edu
http://www.amherst.edu/~ljnelson/
Good, cheap, fast: pick two.


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

Date: Thu, 02 Nov 2000 17:16:56 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Double fork trick: why does grandkid avoid becoming a zombie?
Message-Id: <3A019378.2E105650@fujitsu-siemens.com>

Laird Nelson wrote:
> =

> Referencing
> http://www.perl.com/pub/doc/manual/html/pod/perlfunc/fork.html, which
> outlines the double-fork trick as follows:
> =

>     unless ($pid =3D fork) {
>         unless (fork) {
>             exec "what you really wanna do";
>             die "no exec";
>             # ... or ...
>             ## (some_perl_code_here)
>             exit 0;
>         }
>         exit 0;
>     }
>     waitpid($pid,0);
> =

> The grandchild of the original spawning process--the grandchild's path
> of execution is inside the second "unless" block--apparently does not
> become a zombie because its parent process ID somehow magically becomes=

> that of the init process.  My question is, how? why?  Nothing in fork(2=
)
> that I can see (note: that I can see :-)) implies that a forked child's=

> child will somehow magically get assigned to the init process as a
> child.

It's not magic, it's simply the fact that when your parent dies
(unless(fork) { ... } exit 0;), init becomes your parent!

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)


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

Date: Thu, 2 Nov 2000 07:25:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: embedded variables in a file
Message-Id: <slrn902n9d.dst.tadmc@magna.metronet.com>

On Thu, 02 Nov 2000 13:27:05 +0100, m.nine.six <m.nine.six@freesurf.ch> wrote:

>i have some vars embedded in the text file i wishes to read... and when
>i print the contents, those vars are just printing as $var, rather than
>the contents of $var...


You seem to be missing the distinction between what is code
and what is data.


Perl FAQ, part 4:

   "How can I expand variables in text strings?"


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 02 Nov 2000 11:31:14 -0500
From: Ted Zlatanov <tzz@heechee.beld.net>
Subject: Re: embedded variables in a file
Message-Id: <m3y9z2jpyl.fsf@heechee.beld.net>

"m.nine.six" <m.nine.six@freesurf.ch> writes:

> i have some vars embedded in the text file i wishes to read... and when
> i print the contents, those vars are just printing as $var, rather than
> the contents of $var...

Look at the CPAN (http://search.cpan.org) AppConfig module.  It does
expansion of configuration and environment variables.  Consult the
documentation for more details.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Thu, 02 Nov 2000 12:24:28 -0500
From: Fulko Hew <fulko@wecan.com>
Subject: garbage collecting hashes are slow
Message-Id: <3A01A34C.167E@wecan.com>

My app generates and clears a large number of hashes.

ie.

for ($i = 0; $i < 50000; $i++) {
  $b{$i} = $i;
  %b = ();      # optional statement
}

I know this is worthless code, but you get the jist of the problem.

If you do the single sets, (on my machine) each set takes about
55 usec.  Adding the clear statement ups the loop time to 800 usec.

Just setting the key/value happens very quickly, but if the clearing
seems to take more than 10 times as long.

Part of my test suite generates large hashes, and then empties them
once you've done that, clearing even small hashes now take forever.
ie 0.1 seconds.

I'd speculate the garbage collector kicks in, and then it gets
really slow.

Is there a consistantly quick way to clear a hash?


------------------------------------------------------------------------
Fulko Hew,                           Voice:  905-333-6000  x 6010
Senior Engineering Designer,         Direct: 905-333-6010
Northrop Grumman-Canada, Ltd.        Fax:    905-333-6050
777 Walkers Line,                    Home:   fulko%fkhew@wecan.com
Burlington, Ontario, Canada, L7N 2G1 Work:   fulko@wecan.com


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

Date: 02 Nov 2000 18:35:26 +0100
From: uliw@erdw.ethz.ch (Ulrich G. Wortmann)
Subject: gnupg/pgp blues? (Crypt::PGP, et al.)
Message-Id: <m3d7gegtup.fsf@bonk.ethz.ch>

Hi There,

im trying desperatly to get one of the perl gpg interfaces to get to
work. But regardless which packages I use, it never works. I assume, I
stumble over some pretty obvious things.

With the latest Crypt::Pgp module, I have e.g. the following problem:

1) a secret key exists:

sec  1024D/844444D7 2000-11-02 Uli Wortmann (Uli) <uliw@erdw.ethz.ch>

in my perl code I have:

$gpg = new Crypt::GPG;
$gpg->gpgbin ($path); 
$gpg->secretkey ($key); 
$gpg->passphrase ($phrase); 
$gpg->debug(1);
$gpg->armor (1); 
@message = ("hello","you","\n\n","cheers\n");
$signed = $gpg->sign(@message); 

running this little snipped fails always with

        no default secret key: secret key not available
        gpg: signing failed: secret key not available   

where $key is defined as

        $key = 0x844444D7;

using a name to identify the key, fails likewise, with a complaint
over a nonumeric value. However, running this on the command-line,
works fairly well.

If anybody knows what's going on, I'd be grateful for a hint

        Cheers

                Uli
PS: I'm using GnuPG v1.0.1c-SuSE, and Perl 5.004,
-- 
	Uli Wortmann
	Dept. of Geology       Fax (Switzerland) (1) 632  1030
	ETH-Zuerich            Fon                        3694
        Visit the SPOC-team at http://www.spoc.ethz.ch


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

Date: 2 Nov 2000 07:33:08 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: how to make a read from a socket non-blocking
Message-Id: <3a017b24@cs.colorado.edu>

In article <OEoL9FNRAHA.179@net025s>, dick dijk <ddijk@hetnet.nl> wrote:
>Hello,
>
>I wrote a client program that reads from a socket, but I found out that the
>read is blocking (if there is nothing to read
>the program hangs).
>
>Does anyone know how to make this read non-blocking.

Yes: C programmers know how to do it.  You can, of course, do it 
their way.

You should grep the pods for blocking:

% perlhelp blocking
perlcygwin:Win9x does not correctly report C<EOF> with a non-blocking read on a
perldelta:(like making it non-blocking) and then call connect() manually.
perldelta:IO::Socket::connect now uses non-blocking IO instead of alarm()
perlfaq:=item * How do I open a file without blocking?
perlfaq5:To open a file without blocking, creating if necessary:
perlfaq8:blocking by using sysopen() and C<O_RDWR|O_NDELAY|O_NOCTTY> from the
perlfaq8:=item non-blocking input
perlfaq8:If you are doing a blocking read() or sysread(), you'll have to
perlfaq8:L<perlfunc/alarm>).  If you have a non-blocking open, you'll likely
perlfaq8:have a non-blocking read, which means you may have to use a 4-arg
perlfaq8:blocking flock() in L<perlipc/"Signals"> or chapter 6 of the Camel.
perlfaq8:the section on signals, especially the time-out handler for a blocking
perlfaq8:=head2 How do I open a file without blocking?
perlfaq8:non-blocking reads (most Unixish systems do), you need only to use the
perlfunc:LOCK_SH or LOCK_EX then C<flock> will return immediately rather than blocking
perlfunc:non-blocking at the system level.  You'll have to negotiate C<$|>
perlfunc:then you can do a non-blocking wait for all pending zombie processes.
perlfunc:Non-blocking wait is available on machines supporting either the
perlipc:number of seconds.  Then try your blocking operation, clearing the alarm
perlipc:        flock(FH, 2);   # blocking write lock
perlopentut:    O_NONBLOCK          Non-blocking access
perlopentut:To open a file without blocking, creating one if necessary:
perlopentut:socket, you can set them to be non-blocking using C<fcntl>:
perlopentut:        or die "can't set non blocking: $!";
perlopentut:Here's how to get a blocking shared lock on a file, typically used
perlopentut:You can get a non-blocking lock by using C<LOCK_NB>.
perlopentut:if you're going to be blocking:
perlthrtut:threads, if one thread blocks they all do.  Typical blocking activities
perlthrtut:blocking.  With kernel threads, things that block a single thread don't

See also the FileHandle manpage, or its description in the appropriate
chapter of the 3rd edition of the Camel, where it reads as follows:

    HANDLE->blocking(EXPR)

        Called with an argument, enables non-blocking I/O if the
        argument is false, and disables non-blocking (that is,
        enables blocking) if the argument is true. The method returns
        the previously set value (which is still the current setting
        if no argument was given). On error, blocking sets $! and
        returns undef.  This could be done using fcntl directly,
        but the FileHandle interface is much easier to use.

In fact, the Camel mentions blocking some thirty times or so.

--tom


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

Date: Thu, 02 Nov 2000 16:06:11 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: i'm in 'use vars' hell
Message-Id: <3a0190f3.70bc$382@news.op.net>

In article <Zd4M5.11940$Wq1.7704488@nnrp5-w.sbc.net>,
Brian McDonald <mcdonabNO@SPAMyahoo.com> wrote:
>i believe i'm in 'use vars' hell. and i hope that someone can propose an
>alternate solution to the one that is making me burn.

How about if you turn off 'strict vars'?  Then you can use all the
global variables you want to without declaring them.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Thu, 02 Nov 2000 19:04:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: i'm in 'use vars' hell
Message-Id: <cne30t0jeq27c3k5keps867ub4dirl9bvj@4ax.com>

Brian McDonald wrote:

>what method will allow me to *not* have to explicitly name every variable in
>the 'use vars' declaration?

	no strict 'vars';

;-)

-- 
	Bart.


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

Date: Thu, 02 Nov 2000 18:51:59 GMT
From: msalerno@my-deja.com
Subject: Is there a way to get all PID's within Perl ?
Message-Id: <8tsd4a$i3q$1@nnrp1.deja.com>

pretty much what the title asks.  I would like to be able to get a list
of all running proccesses.

I could use:
@pids = `/usr/bin/ps -ef -o user -o pid -o args`;

But I would rather not have to call any external programs.


Thanks,
Matt


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


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

Date: 2 Nov 2000 07:35:19 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Keeping a List of Objects
Message-Id: <3a017ba7@cs.colorado.edu>

In article <Pine.GSO.4.21.0011020838340.25313-100000@crusoe.crusoe.net>,
Jeff Pinyan  <japhy@pobox.com> wrote:
>I didn't know there was a preferred means to weaken a reference, so I
>thought Devel::Peek was the way to go.

The Camel reads, at the very end of its references chapter:

    A similar situation can occur with I<caches>--repositories of
    data designed for faster-than-normal retrieval.  Outside the
    cache, there are references to data inside the cache.  The
    problem occurs when all of those references are deleted, but
    the cache data with its internal reference remains.  The existence
    of any reference prevents the referent from being reclaimed by
    Perl, even though we want cache data to disappear as soon as
    it's no longer needed.  As with circular references, we want a
    reference that doesn't affect the reference count, and therefore
    doesn't delay garbage collection.

    I<Weak references> solve the problems caused by circular
    references and cache data by allowing you to "weaken" any
    reference; that is, make it not affect the reference count.
    When the last non-weak reference to an object is deleted, the
    object is destroyed and all the weak references to the object
    are automatically freed.

    To use this feature, you need the WeakRef package from CPAN,
    which contains additional documentation.  Weak references are
    an experimental feature.  But hey, somebody's gotta be the
    guinea pig.

--tom


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

Date: Thu, 2 Nov 2000 11:18:18 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Keeping a List of Objects
Message-Id: <Pine.GSO.4.21.0011021108450.25313-100000@crusoe.crusoe.net>

On Nov 2, Tom Christiansen said:

>The Camel reads, at the very end of its references chapter:

I don't have the new Camel (yet?).

Hmm, grepping the POD docs, there's VERY little about weak
refs.  perldelta, perltoc, perldiag.  Why isn't there anything in
perlref?  Or perlobj (or some related place)?  At least a "here's some
crufty stuff..." note.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/





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

Date: 2 Nov 2000 09:23:09 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Keeping a List of Objects
Message-Id: <3a0194ed@cs.colorado.edu>

   [ An expedited courtesy copy of this Usenet posting was also mailed
     to the cited author. ]

In article <Pine.GSO.4.21.0011021108450.25313-100000@crusoe.crusoe.net>,
Jeff Pinyan  <japhy@pobox.com> wrote:

+---------------------------------------------------------------------------+
| +-----------------------------------------------------------------------+ |
| | +-------------------------------------------------------------------+ | |
| | | You are wicked and annoying to have sent me a stealth-copy via    | | |
| | | private mail.  Now I have to waste my life replying twice to make | | |
| | | sure other people see the answer as well.                         | | |
| | +-------------------------------------------------------------------+ | |
| +-----------------------------------------------------------------------+ |
+---------------------------------------------------------------------------+

Fix your broken newsreader, please.

>>The Camel reads, at the very end of its references chapter:
>
>I don't have the new Camel (yet?).
>
>Hmm, grepping the POD docs, there's VERY little about weak
>refs.  perldelta, perltoc, perldiag.  Why isn't there anything in
>perlref?  Or perlobj (or some related place)?  At least a "here's some
>crufty stuff..." note.

Because it's experimental and not included standard.
You have to fetch some cpan crud.

--tom


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

Date: Thu, 2 Nov 2000 12:33:48 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: killfiles (was Re: Perl style and module searches)
Message-Id: <slrn9039bs.evs.tadmc@magna.metronet.com>

On 2 Nov 2000 08:16:15 -0700, Tom Christiansen <tchrist@perl.com> wrote:
>In article <3A00BB1E.41FDF922@hotmail.com>,
>Dave E  <dave_at_hm@hotmail.com> wrote:
>>I have 2 newbie questions:
>
>Word to the wise: "newbie" is a severely negative flashword.  In
>fact, it's in my subject killfile.  It's just a cutesie-tootsie way
>for Muffy to expressie that she's a "beginner"--or, if you prefer
>a fancier term, then I suppose a "neophyte".


It is in my killfile too, but not for that reason.

I don't mind helping neophytes. I actually _like_ helping
them. So I would not kill on it for the reasons given above.

Yet I _do_ killfile it (and likely miss out on lots of ones
I wouldn't have minded reading, oh well).

Why?

Because, in my experience, it very often is used as an
"excuse" for not following standard netiquette.

That is, it isn't being "new to Perl" that makes me kill them,
it is being "new to Usenet" that makes me kill them.

I find that more often than not, if I open up a "newbie"
article, I will find someone wanting me to read the docs to them.

So I just don't open them.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 2 Nov 2000 13:12:11 -0500
From: David Coppit <newspost@coppit.org>
Subject: Re: Need suggestions on optimization
Message-Id: <Pine.GSO.4.21.0011021304400.24601-100000@mamba.cs.Virginia.EDU>

On Thu, 2 Nov 2000, brian d foy wrote:

> > I was wondering if anyone had some suggestions for me on optimizing
> > some code.
> 
> profile the code and think about the slow bits first. :)

Thanks for the suggestion. As I noted in my original post, I did
profile the code and the results suggest that there are no obvious
slow parts.

For example, here are the lines of code that use more than a few
percent of the time:

count wall tm  cpu time
 4021 14.48674 14.30000     $matchesBody = ($body_buffer =~
33448 6.868687 2.980000   my $paragraph = <$fileHandle>;
33448 0.967850 2.200000     elsif ($paragraph =~
36200 0.489779 1.870000 return 1 unless $DEBUG;

The first line is where I match the body of the email. The second is where I
read the next paragraph from the mailbox.

From DProf:

Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 81.7   15.01 18.834      1   15.018 18.834  main::ProcessMailFile
 14.6   2.697  2.676   4021   0.0007 0.0007  main::GetRestOfBody
 5.05   0.929  0.902   4021   0.0002 0.0002  main::AnalyzeHeader

ProcessMailFile is the main loop where the the matching is done on the
header and/or body of an email. GetRestOfBody reads an email up to the
next email or the end of the file.

David



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

Date: Thu, 02 Nov 2000 16:44:23 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Newbie:  How to COMPARE DATES in Perl???
Message-Id: <HRgM5.10331$rl.882352@newsread2.prod.itd.earthlink.net>

I'm very new to Perl and need to know how I would begin to go about coding
for the following needs:

1)  Does DateA occur before DateB?

2)  What is the difference in days/weeks/months/years between DateA and
DateB?

How would I begin to go about coding for these types of things in Perl?
Thanks in advance.




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

Date: 2 Nov 2000 17:11:34 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Newbie:  How to COMPARE DATES in Perl???
Message-Id: <slrn903826.c05.clay@panix3.panix.com>

On Thu, 02 Nov 2000 16:44:23 GMT, Alan Mailer <clarityassoc@earthlink.net> 
wrote:

>I'm very new to Perl and need to know how I would begin to go about coding
>for the following needs:
>
>1)  Does DateA occur before DateB?
>
>2)  What is the difference in days/weeks/months/years between DateA and
>DateB?
>
>How would I begin to go about coding for these types of things in Perl?
>Thanks in advance.

Check out the Perl modules, Date::Calc and Date::Manip.

-- 
Clay Irving <clay@panix.com>
Socialism is the equal distribution of poverty. 


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

Date: Thu, 02 Nov 2000 18:51:29 GMT
From: bluearchtop@my-deja.com
Subject: Pattern Matching /isg
Message-Id: <8tsd3d$i38$1@nnrp1.deja.com>

Can someone help me with this one. Let's say I have the following:
$str=<<_EOF_;
<LOOP>
something...
</LOOP>

blah

<LOOP>
something
</LOOP>
 ...
_EOF_

I want to pull out what is in between the <LOOP> </LOOP> blocks:

$str=~s/<LOOP>(.+)<\/LOOP>/&myfunc($1)/is  works fine if there is just
one loop block, but it is being greedy if multiple Loop blocks. I just
want it to hit the first ending loop tag. I've tried .? and /isg and
that didn't work.

Thanks!



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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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