[10197] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3790 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 22 21:08:26 1998

Date: Tue, 22 Sep 98 18:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 22 Sep 1998     Volume: 8 Number: 3790

Today's topics:
        -e file test? <kquinn@sk.sympatico.ca>
    Re: -e file test? <uri@camel.fastserv.com>
    Re: -e file test? <eashton@bbnplanet.com>
        ANNOUNCE: Config::Access 0.01 <tpot@acsys.anu.edu.au>
        ANNOUNCE: HMAC::MD5 v0.01 (Clinton Wong)
        Announce: HMAC::SHA1 0.01 (Clinton Wong)
        Announce: HTML::EP 0.1101 <joe@ispsoft.de>
        ANNOUNCE: XML::Grove 0.04 <ken@bitsko.slc.ut.us>
        Announcing grepmail version 1.7 <dwc3q@cs.virginia.edu>
    Re: Any Perl 5.005 binary build for win32? <Savage.Ron.RS@bhp.com.au>
        Can't locate loadable object Module? <bellears@deakin.edu.au>
    Re: Change chars in STDOUT? <garry@america.net>
    Re: changing $ 'variables' in regexprs (John Moreno)
    Re: changing $ 'variables' in regexprs <uri@camel.fastserv.com>
    Re: Hashes springing into existence [Was: more regex/pa (Tye McQueen)
    Re: Hashes springing into existence [Was: more regex/pa <uri@camel.fastserv.com>
    Re: Hashes springing into existence [Was: more regex/pa <tchrist@mox.perl.com>
    Re: Hashes springing into existence [Was: more regex/pa <tchrist@mox.perl.com>
    Re: Help needed using LWP (Michael Budash)
        How to count match pattern? hup@addall.com
        MLDBM object methods (Steve Manes)
        New modules: NetServer-Generic-0.03 and NetServer-SMTP- (Charlie Stross)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 22 Sep 1998 15:28:02 -0600
From: Ken Quinn <kquinn@sk.sympatico.ca>
Subject: -e file test?
Message-Id: <36081662.B1083815@sk.sympatico.ca>

I am having a problem with the following and was hoping someone may be
able to help.
$a = <STDIN>;       #using  filename  | script.pl    (to test from
pipe).
chomp($a);
if(-e "$a") {
print "File already exists \n";
exit;
}
{
open(FILE, ">$a");
print FILE "data \n";
print "Made file \n";
exit;
}
If the file does not exist it will be made and "Made file" printed to
screen.
If the file does exist it is to print to screen "File already exists".
This works fine if I use (-e filename) but when I use (-e "$a") as above

I get "Made file \n"; printed to screen.
Thanks, Ken



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

Date: 22 Sep 1998 20:04:22 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: Ken Quinn <kquinn@sk.sympatico.ca>
Subject: Re: -e file test?
Message-Id: <sarg1djg0e1.fsf@camel.fastserv.com>

>>>>> "KQ" == Ken Quinn <kquinn@sk.sympatico.ca> writes:

  KQ> I am having a problem with the following and was hoping someone may be
  KQ> able to help.

works fine by me.

but your code could use major formatting and other improvements


  KQ> $a = <STDIN>;       #using  filename  | script.pl    (to test from
  KQ> pipe).
  KQ> chomp($a);
  KQ> if(-e "$a") {

no need for the "". -e $a is just fine

  KQ> print "File already exists \n";

no need for the blank before \n. same on other prints

  KQ> exit;
  KQ> }

indent your code. it make it easier for al of us to read it.

  KQ> {

no need for this block. the previous if exits.

  KQ> open(FILE, ">$a");

always check the result of open

  KQ> print FILE "data \n";
  KQ> print "Made file \n";
  KQ> exit;
  KQ> }

  KQ> If the file does exist it is to print to screen "File already exists".
  KQ> This works fine if I use (-e filename) but when I use (-e "$a") as above

  KQ> I get "Made file \n"; printed to screen.

as i said it seems to work. can you give a better example of it failing?
maybe how you call it or whether the file exists? i tried it before and
after the fiel was created and it worked fine.

hth,

uri

-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 23 Sep 1998 00:27:43 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: -e file test?
Message-Id: <36083E14.599066F3@bbnplanet.com>

Ken Quinn wrote:

> I am having a problem with the following and was hoping someone may be
> able to help.
> This works fine if I use (-e filename) but when I use (-e "$a") as above

$file = <STDIN>;
chop $file;
open(FILE, ">/tmp/foobar") or die $!;
print FILE "$file";
if (-e "/tmp/foobar") {
        print "Hey, wow, it worked! \n";
   } else {
        print "Bummer, it didn't!\n";
  }

You might also try perldoc -f {open,sysopen}
HTH.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: 23 Sep 1998 00:02:09 GMT
From: Tim Potter <tpot@acsys.anu.edu.au>
Subject: ANNOUNCE: Config::Access 0.01
Message-Id: <6u9dq1$n7l$1@news.neta.com>

Announcing Config::Access, a perl module for simple text-file based
access control based on the TCP wrappers access control language.
Available soon from a CPAN near you.

Basically this module is a side-effect of a project I did at work.
Hopefully someone else will find it useful.


Tim.

NAME
       Config::Access - Perform simple access control

SYNOPSIS
           use strict;                  # not optional (-:
           use Config::Access;


DESCRIPTION
       The Config::Access module provides a method of
       authenticating arbitrary client/service pairs in a way
       very similar to that provided by the TCP wrappers by
       Wietse Venema <wietse@wzv.win.tue.nl>.

       This module can be useful for restricting access to
       certain parts of a script to a certain domain.  For
       example, a front end program to some device might deny
       certain users access to certain commands or only allow
       trusted users access to dangerous commands.

       The access control language is very similar to the access
       control language specified in hosts_access(5) for the TCP
       wrappers.  Two configuration files specify access rules.
       A file ending in .allow specifies rules to allow access
       and a file ending in .deny specifies rules to deny access.
       The prefix of these files is specified when a
       Config::Access object is created.

ACCESS CONTROL FILES
       As per the TCP wrappers, a request for authorisation
       consults the .allow and .deny files.  The search stops at
       the first match.

       o Access is granted if a $client/$service matches a rule
            in the .allow file.

       o Access is denied if a $client/$service matches a rule in
            the .deny file.

       o Otherwise, if no match is made access is granted.

ACCESS CONTROL RULES
       Access control rules appear in the configuration files in
       the following format.

           service_list : client_list

       Each item in a list is separated by a comma and optional
       whitespace.  Newlines and lines beginning with a '#'
       character are ignored.  A line may be continued if a
       backslash character is present as the end of the line.

       A service or client may be specified as the string 'ALL'
       which means it will be matched by anything.  An optional
       parameter to the access_query method described below
       allows the caller to determine whether the request was
       granted (or denied) using a rule containing the ALL
       wildcard.

       Config::Access also supports IP address matching of
       clients and services using the network/netmask number
       format.

       The EXCEPT operator present in the TCP wrappers access
       control language is not supported.




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

Date: 23 Sep 1998 00:04:17 GMT
From: clintdw@netcom.com (Clinton Wong)
Subject: ANNOUNCE: HMAC::MD5 v0.01
Message-Id: <6u9du1$n7u$1@news.neta.com>

HMAC::MD5 v0.01 has been uploaded to PAUSE and should be available
on CPAN in a few days.  It is also available at:

http://postmaster.net/~clintdw/src/HMAC-MD5-latest.tar.gz

Since postmaster.net is having DNS problems, try:
http://204.71.106.24/~clintdw/src/HMAC-MD5-latest.tar.gz

Given a key, HMAC MD5 computes a digest.  It is believed to
be stronger than plain MD5.  See RFC 2104 and 1321 for
details.

Newer protocols (like CHAP auth in SOCKS v5) require HMAC MD5
instead of regular MD5.

Regards,
Clinton
-- 
For a good time, read RFC 2324.                 http://postmaster.net/~clintdw/




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

Date: 23 Sep 1998 00:04:26 GMT
From: clintdw@netcom.com (Clinton Wong)
Subject: Announce: HMAC::SHA1 0.01
Message-Id: <6u9dua$n7v$1@news.neta.com>

HMAC::SHA1 has been uploaded to CPAN and should be available in a few days.
It is also available at:
http://postmaster.net/~clintdw/src/HMAC-SHA1-latest.tar.gz

Cheers,
Clinton

NAME
       HMAC::SHA1 - Perl module to compute an HMAC SHA-1 digest.

SYNOPSIS
        use HMAC::SHA1;
        hex($string, $key) returns a 20 byte digest in binary form.
        hexhash($string, $key) returns a 20 byte digest as printable hex.


DESCRIPTION
        This module computes an HMAC SHA-1 digest as specified by RFC 2104.


EXAMPLE
        use HMAC::SHA1;
        print HMAC::SHA1::hexhash("what do ya want for nothing?", "Jefe"),
              " should be effcdf6ae5eb2fa2d27416d5f184df9c259a7c79\n";

SEE ALSO
        RFC 2104        - HMAC specification.
        RFC 2202        - HMAC test cases.
        FIPS PUB 180-1  - SHA-1 specification.

-- 
For a good time, read RFC 2324.                 http://postmaster.net/~clintdw/




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

Date: 23 Sep 1998 00:06:28 GMT
From: Jochen Wiedmann <joe@ispsoft.de>
Subject: Announce: HTML::EP 0.1101
Message-Id: <6u9e24$n9v$1@news.neta.com>

Hello,

I'd like to announce the first public release of HTML::EP, a
modular, extensible system for Perl embedded HTML, similar to
HTML::EmbPerl or HTML::Mason.

HTML::EP4s features include:

  - Runs as a standalone CGI binary or with mod_perl.
  - Uses HTML syntax, thus well usable from within HTML editors
    and better understandable for Non-programmers. This is similar
    to MiniVend.
  - Extensible via modules, currently available modules include
  - Localization; one HTML file may appear in multiple languages,
    see

	http://www.heckerwerke.de/cgi/ep.cgi/mail/input.ep

    and

	http://www.heckerwerke.de/cgi/ep.cgi/mail/input.ep?language=en

    for running examples
  - Session management similar to Apache::Session
  - Support for connecting to SQL engines via DBI; this is much
    simpler than what DBIx::RecordSet offers, but hopefully also
    easier to handle.

For running examples, see the SNMP::Monitor package on

  http://www.zvw.de/snmpmon_public/

The package is available on any CPAN mirror, in particular

  ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/id/JWIED

On the TODO list are:

  - Speedup by moving the Parser to XS code
  - Example HTML files

Any feedback highly appreciated,

Jochen


-- 
Jochen Wiedmann						joe@ispsoft.de
The principle virtues of a programmer are		+49 7123 14887
laziness, impatience, and hubris. (Larry Wall)




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

Date: 23 Sep 1998 00:07:12 GMT
From: Ken MacLeod <ken@bitsko.slc.ut.us>
Subject: ANNOUNCE: XML::Grove 0.04
Message-Id: <6u9e3g$na9$1@news.neta.com>

The XML::Grove module defines a set of objects representing XML
documents.

XML::Grove includes modules for accessing the XML objects, converting
XML content to strings, and writing XML.

XML::Grove is making it's way to CPAN at:

    $CPAN/authors/id/KMACLEOD/XML-Grove-0.04.tar.gz

and is mirrored at:

    ftp://ftp.uu.net/vendor/bitsko/gdo/
    http://unix.hensa.ac.uk/ftp/mirrors/uunet/vendor/bitsko/gdo/
    ftp://unix.hensa.ac.uk/mirrors/uunet/vendor/bitsko/gdo/
    http://bitsko.slc.ut.us/~ken/perl-xml/  (slow serial line)

The last link also includes HTML copies of the PODs and additional
examples.

XML::Grove requires XML::Parser from

    http://www.netheaven.com/~coopercc/xmlparser/intro.html

Changes since 0.03:

    * Added support for Clark Cooper's updates to XML::Parser
    * several bug fixes

There is a major, but simple to fix, backward incompatible change
using the new XML::Parser.  Prior to 0.04, you would parse the XML
document and get the grove using this code:

    $parser->parsefile($file_name);
    $grove = $parser->{Grove};

With the new XML::Parser, the grove is returned from `parsefile',
these lines should be changed to:

    $grove = $parser->parsefile($file_name);

The old method is still required with the original XML::Parser 0.0.

-- 
  Ken MacLeod
  ken@bitsko.slc.ut.us




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

Date: 23 Sep 1998 00:04:57 GMT
From: David Coppit <dwc3q@cs.virginia.edu>
Subject: Announcing grepmail version 1.7
Message-Id: <6u9dv9$n81$1@news.neta.com>


grepmail 1.7: A Perl script for searching email archives for patterns, in
the spirit of grep. Outputs full email messages. This new version is
faster and more robust.

grepmail supports gzip'ed files, -i, and -v, and can be piped to.
Please report any bugs, modifications, or suggestions.


Available on CPAN at:
$CPAN/authors/id/D/DC/DCOPPIT/grepmail-1.7.tar.gz

(Goto http://www.perl.org/ if you don't know how to get to CPAN.)

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

usage: grepmail [-vi] [-d "datespec"] <expr> <files...>

-i Ignore case in the search expression
-v Output emails that don't match the expression

Date specifications must be of the form of:
a date like "today", "1st thursday in June 1992", "05/10/93",
  "12:30 Dec 12th 1880", "8:00pm december tenth",
OR "before", "after", or "since", followed by a date as defined above,
OR "between <date> and <date>", where <date> is defined as above.

You can also pipe to grepmail.

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

Here are a few examples:

Get all email that you mailed yesterday
- grepmail -d "yesterday" . sent-mail

Get all email that you mailed before the first thursday in June 1998 that
pertains to research:
- grepmail -d "before 1st thursday in June 1992" research sent-mail

Get all email you received since 8/20/98 that wasn't about research,
ignoring case:
- grepmail -i -d "since 8/20/98" -v research saved-mail

Get all email about research but not about software:
- grepmail research saved-mail | grepmail -v software

David

_________________________________________________________________________
David Coppit - Graduate Student        coppit@cs.virginia.edu
The University of Virginia             http://www.cs.virginia.edu/~dwc3q
                "For I am a Bear of Very Little Brain,
             and long words Bother me" - Winnie the Pooh







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

Date: 22 Sep 1998 23:45:50 GMT
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Any Perl 5.005 binary build for win32?
Message-Id: <01bde683$b2295780$87ea1286@steelres-pcm657.resmel.bhp.com.au>

Nope: This version is also sick:
Registry.obj : error LNK2001: unresolved external symbol _SetCPerlObj

-- 
Ron Savage
Home (preferred): rpsavage@ozemail.com.au
Office: Savage.Ron.RS@bhp.com.au
http://www.ozemail.com.au/~rpsavage

[snip]



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

Date: Wed, 23 Sep 1998 10:29:16 +1000
From: Mick <bellears@deakin.edu.au>
Subject: Can't locate loadable object Module?
Message-Id: <360840DB.6E1812DC@deakin.edu.au>

I'm running (Redhat 5.1) Apache 1.3.1 with mod_perl, and when I try to
start up httpd, I get
Cant locate loadable object for module DBI in @INC. .......
DBI.pm contains the offending line
use DBI () on line 3.
Am I missing something, or have I installed wrongly?

Any help is greatly appreciated!
Mick



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

Date: Wed, 23 Sep 1998 00:22:07 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: Change chars in STDOUT?
Message-Id: <36083F7E.4377AD9@america.net>

You probably also want to handle signals like SIGTERM, SIGINT, etc.  In
the signal handler, you can restore the echo.  Using `-isig' may be
inconvenient to users.  

-Garry Williams

Elaine -HappyFunBall- Ashton wrote:
> 
> Christopher Marquis wrote:
> 
> > I'm trying to do a cute little password routine. But I can't think of a
> > way of replacing everything typed to echo back a "*" or something like
> > it instead of what is really being typed.
> 
> print "Password: ";
> system ( '/usr/bin/stty -echo -isig' );
> $password = <STDIN>;
> system ( '/usr/bin/stty echo isig' );
> print ( "\n" );
> 
> An example that would work on Solaris. man stty.
> 
> e.
> 
> "All of us, all of us, all of us trying to save our immortal souls, some
> ways seemingly more round-about and mysterious than others. We're having
> a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Tue, 22 Sep 1998 19:15:03 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: changing $ 'variables' in regexprs
Message-Id: <1dfrub1.dso3464h1wyfN@roxboro0-052.dyn.interpath.net>

Uri Guttman <uri@camel.fastserv.com> wrote:

> >>>>> "JM" == John Moreno <phenix@interpath.com> writes:
> 
>   JM> David Rouse <4newsargus@mail.entrsft.com> wrote:
>   >> I really need to be able to do is force $1 into ALL CAPS. Sadly,
-snip-
>   JM> Run this and see if you can't figure it out:
> 
>   JM> $this = "that";
> 
>   JM> $this =~ s/(t)/uc $1/e;
> 
>   JM> print $this;
> 
> it would be better to use \U, then you don't need /e.
> 
> and printing $this without a \n would make it invisible after the next
> prompt was printed.

Really?  I'm not running it from the prompt.

>   JM> (again I say - this ought to be mentioned in perlre.pod
>   JM> and not just in perlop.pod).
> 
> it is mentioned in perlre, just in the pattern replacement section. it
> says it is doublequotish and \U (and the other flavors of case changing)
> works.

/e is only mentioned tangentially:

### from perlre.pod ###
WARNING on \1 vs $1
-snip-
However, if you get into the habit of doing that, you get yourself into
trouble if you then add an /e modifier.
### from perlre.pod ###

Also - it's not clear (or it at least it wasn't to me) that when \U is
mentioned that it works on both sides of a substitution.

-- 
John Moreno


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

Date: 22 Sep 1998 19:56:20 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: changing $ 'variables' in regexprs
Message-Id: <sariuifg0rf.fsf@camel.fastserv.com>

>>>>> "JM" == John Moreno <phenix@interpath.com> writes:

  JM> Uri Guttman <uri@camel.fastserv.com> wrote:
  >> >>>>> "JM" == John Moreno <phenix@interpath.com> writes:
  >> 
  JM> $this = "that";
  >> 
  JM> $this =~ s/(t)/uc $1/e;

  JM> /e is only mentioned tangentially:

  JM> ### from perlre.pod ###
  JM> WARNING on \1 vs $1
  JM> -snip-
  JM> However, if you get into the habit of doing that, you get yourself into
  JM> trouble if you then add an /e modifier.
  JM> ### from perlre.pod ###

since you used uc in the replacement string you had to use /e. my point
was to use \U and you don't need /e or uc.

  JM> Also - it's not clear (or it at least it wasn't to me) that when \U is
  JM> mentioned that it works on both sides of a substitution.

from perlop.pod

<QUOTE>
If the delimiter chosen is single quote, no variable interpolation is
done on either the PATTERN or the REPLACEMENT.  Otherwise, if the
PATTERN contains a $ that looks like a variable rather than an
end-of-string test, the variable will be interpolated into the pattern
at run-time.
</QUOTE>


the replacement is s/// is a double quotish string so all \U and its ilk
work just fine. the text doesn't mention anything but variable
interpolation but that implies double quotes. i think camel says it
better but i don't have it at work.

uri

-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 22 Sep 1998 18:33:57 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6u9c55$ecp@fohnix.metronet.com>

) > cberry@cinenet.net (Craig Berry) writes:
) 
) >> exists $foo{bar}{quux}
) >> 
) >> creates $foo{bar} if it didn't exist already. 

) >>>>> "Martin" == Martin Gregory <mgregory@asc.sps.mot.com> writes:
) 
) Martin> I have been bitten by this too.  I wonder why it happens?   Is there
) Martin> ever a case where this is a desirable effect?

Randal Schwartz <merlyn@stonehenge.com> writes:
) 
) If you really wanna see if $foo{bar} exists, ask that first.
) Otherwise, don't worry whether it's being stuffed or not.

So why have C<use strict "refs"> at all?

But seriously, it would be nice to be able to prevent autovivication
so you can catch typos.  Why I just ran into one today.  I wrote:

    @{$DiskInfo{PrtnSeq}}

when I meant to write:

    @{$DiskInfo{PartnSeq}}

No error message and no way to get an error, just an C<undef>
silently turned into an empty array.  I turn on the standard
helpers ("-w" and C<use strict>) so most places that I try to
use an C<undef> I get a warning.  This is a place where I've
always thought I should get one.

Of course, it would be unPerlish to give such a warning by
default, but "-w" or C<use strict "refs"> should enable such.
Given existing practice, this will now have to be done with
a new pragma, however.

This is one of the very first surprises I found back when I was
just learning about these nifty new Perl references.  Since I
didn't have much experience then, I didn't make a big deal of it.

I prefer to write code where I explicitly do:

    $DiskInfo{PartnSeq}= [];

before I ever talk about C<@{$DiskInfo{PartnSeq}}> or
C<$DiskInfo{PartnSeq}->[0]>.  It just makes more sense to me
that way.  And I'd really like to be able to have Perl enforce
this because it would catch a lot of bugs for me.

Actually, I'm still surprised that autovivication became the
default behavior.  I have a hard time coming up with code that
is significantly complicated by forcing you to create your
references before you run off and start using them.  It just
seems unnatural to be able to use a reference that you haven't
even created yet.  And my personal experience says that it is
also very error prone.

I can see Perl letting you do this just like you can use a
variable you haven't defined yet in an equation and you magically
get 0.  But you need to be able to prevent that in "big projects"
so you can catch errors earlier in the development process (for
the same reasons that the FAQs ask whether you have C<use strict>
in your code>).
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: 22 Sep 1998 20:12:09 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <sard88ng011.fsf@camel.fastserv.com>

>>>>> "TM" == Tye McQueen <tye@fohnix.metronet.com> writes:


  TM> I prefer to write code where I explicitly do:

  TM>     $DiskInfo{PartnSeq}= [];

  TM> before I ever talk about C<@{$DiskInfo{PartnSeq}}> or
  TM> C<$DiskInfo{PartnSeq}->[0]>.  It just makes more sense to me that
  TM> way.  And I'd really like to be able to have Perl enforce this
  TM> because it would catch a lot of bugs for me.

  TM> Actually, I'm still surprised that autovivication became the
  TM> default behavior.  I have a hard time coming up with code that is
  TM> significantly complicated by forcing you to create your references
  TM> before you run off and start using them.  It just seems unnatural
  TM> to be able to use a reference that you haven't even created yet.
  TM> And my personal experience says that it is also very error prone.

a very common usage is when you push things into a anon array in a
hash. you may not know in advance what the hash keys are so you use code
like this:

	push( @{$hash{$key}}, $val ) ;

if you had to init it, you would have to do this before every push:

	$hash{$key} = [] unless exists $hash{$key} ;

which will slow things down and add repetative code.

uri

-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 23 Sep 1998 00:27:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6u9fa7$793$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, tye@fohnix.metronet.com (Tye McQueen) writes:
:But seriously, it would be nice to be able to prevent autovivication
:so you can catch typos.  Why I just ran into one today.  I wrote:
:
:    @{$DiskInfo{PrtnSeq}}
:
:when I meant to write:
:
:    @{$DiskInfo{PartnSeq}}
:
:No error message and no way to get an error, just an C<undef>
:silently turned into an empty array.  

That's because you were in an lvalue context, so you autovivified.
As an rvalue, you'd have taken a fatal from strict.

--tom
-- 
    "Do we define evil as the absence of goodness?  It seems only logical
    that shit happens--we discover this by the process of elimination."
    	--Larry Wall


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

Date: 23 Sep 1998 00:48:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6u9ggc$793$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Uri Guttman <uri@camel.fastserv.com> writes:
:	push( @{$hash{$key}}, $val ) ;
:if you had to init it, you would have to do this before every push:
:	$hash{$key} = [] unless exists $hash{$key} ;
:which will slow things down and add repetative code.

Well, modulo the obvious:

    push(@{ $hash{$key} ||= [] }, $val);

As seen in PCB chapter 11:

    @residents = @{ $phone2name{$number} || [] };

Which gets around Tye's issue in an rvalue context
(push is lvalue, of course).

--tom
-- 
If I had only known, I would have been a locksmith.  --Albert Einstein


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

Date: Tue, 22 Sep 1998 16:08:45 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Help needed using LWP
Message-Id: <mbudash-2209981608450001@209.204.139.52>

In article <360822B4.2CA2F78F@bbnplanet.com>, Elaine -HappyFunBall- Ashton
<eashton@bbnplanet.com> wrote:

>> Michael Budash wrote:
>> 
>> > trying to use the lwp module to do a post to a remote server in a cgi
>> > called from a secure (https) web form. works fine if the url specified in
>> > not secure, but doesn't work if it's secure. can somebody tell me what i'm
>> > doing wrong? or is it something about secure-to-secure? TIA
>> 
>> From the LWP Readme.
>> 
>> If you want to access sites using the https protocol, then you need to
>> install the Crypt-SSLeay modules first.  (The Net::SSLeay module is not
>> supported any more.)
>> 

thanks... now all i gotta do is get my client's host to "install the
Crypt-SSLeay modules"!

-- 
Michael Budash ~ Michael Budash Consulting
707-255-5371 ~ 707-258-7800 x7736
mbudash@sonic.net


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

Date: Wed, 23 Sep 1998 00:30:20 GMT
From: hup@addall.com
Subject: How to count match pattern?
Message-Id: <6u9fet$v$1@nnrp1.dejanews.com>

Hi,
  I hope this is not a FAQ.
  I wonder how could I find out how many pattern are match/replace?


--AddALL is a book searching and price comparison meta search engine
---------- The free service finds book and compares price among over 20
online bookstores. Please visit http://www.addall.com to save your Time and
Money. ----- Chai-Hup Chen hup@addall.com
--------------------------------------------

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 22 Sep 1998 23:23:03 GMT
From: smanes@NOSPAM.HEREmagpie.com (Steve Manes)
Subject: MLDBM object methods
Message-Id: <362e3073.936590739@news.panix.com>

Can someone tell me how to access the FIRSTKEY, NEXTKEY, etc. DBM
object methods in MLDBM (using GDBM)?  I see them in the MLDBM.pm
module but I can't fnd any docs to explain how to get at them.

Also, LASTKEY and PREVKEY methods appear to be missing.

------------------[ http://www.magpie.com ]-----------=o&>o-------
Steve Manes        smanes [at] magpie.com       N'Yawk, N'Yawk


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

Date: 23 Sep 1998 00:03:58 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: New modules: NetServer-Generic-0.03 and NetServer-SMTP-0.01
Message-Id: <6u9dte$n7s$1@news.neta.com>

I have today uploaded two modules to CPAN: NetServer-Generic-0.03, and
NetServer-SMTP-0.01.

These modules can be found in:

  $CPAN/author/id/C/CH/CHSTROSS

and

  $CPAN/modules/by-module/NetServer

NetServer::Generic implements a class for writing simple TCP/IP servers.
Servers can be configured to fork() (like a traditional UNIX internet
server) or use the select() system call.  A basic allow/deny access
control mechanism is provided.

To write a server, simply create a subroutine that reads from STDIN and
writes to STDOUT. Then create a NetServer::Generic object, configure it,
and pass it a reference to the subroutine. The sub will then be executed
whenever a client attempts to connect to the bound hostname on the
designated socket; input from the socket will go to STDIN, and output
from STDOUT will go back to the client.

(If this sounds like the job inetd does, it is. A future release may
incorporate full inetd/tcpd replacement functionality, implemented in
Perl.)

NetServer::SMTP is a class that provides a minimal SMTP server
interface, as defined in RFC 821  4.5.1 ("Minimum Implementation"). No
attempt to verify the authenticity of the sender is made; no attempt is
made to filter out relay attacks or deliver the mail, and it doesn't
even attempt to check messages for RFC 822 compliance.  Instead, the
mail is spooled in the form of a deep-frozen NetServer::SMTP object,
dropped into the spool directory.

Spooled mail may be transmitted by (a) unfreezing it into a live
NetServer::SMTP object and (b) invoking the send() method on it to
transmit the mail to a designated smarthost.

NetServer::SMTP relies on NetServer::Generic to provide server 
functionality. It should be considered very much an early alpha release;
don't try using it for anything mission-critical just yet!

NetServer::SMTP is part of a work-in-progress, the development of a
compact SMTP server in Perl. An example is included: leafmail, a queueing
SMTP spooler designed for use on a dial-up system with an intermittent
internet connect. (Leafmail batches up mail sent via SMTP while the
system is offline, and can transmit it to an ISP's mail server when the
system goes online.)

(Future planned work includes RFC822 compliance checks, tests for 
indications of spam tainting in the Received: line, a local delivery 
interface, and smarter remote delivery.)

Both the above modules are implemented in 100% Perl and test out on 
Linux and BSDI UNIX. (They are unlikely to work effectively on systems
that do not support the fork() system call, e.g. Win32 and MacOS.) In
addition they use the following modules which are available from CPAN
but are not part of the core Perl 5.004/5.005 distributions:

	Time::CTime    (from Time-modules)
	FreezeThaw     (for NetServer::SMTP)
	ChatBot::Eliza (for one of the examples in NetServer::Generic)
	Mail::Internet (for leafmail, in NetServer::SMTP)




-- Charlie Stross




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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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