[16989] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4401 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 22 03:05:31 2000

Date: Fri, 22 Sep 2000 00:05:13 -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: <969606313-v9-i4401@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 22 Sep 2000     Volume: 9 Number: 4401

Today's topics:
    Re: Accessing Objects in an array (Robert Goff)
    Re: Accessing Objects in an array <jeff@vpservices.com>
    Re: Candidate for the top ten perl mistakes list (Keith Calvert Ivey)
    Re: converting binary string <Kai.Wipplinger@de.bosch.com>
        CR/LF heritage (was Re: Gratuitous incompatibilities) <uri@sysarch.com>
    Re: creating XS wrapper for C functions inport,inportb, <bill@karwin.com>
    Re: deamonize <berube@odyssee.net>
    Re: deamonize <skv@iis.nsk.su>
        email attachment not in body of email using Lite module <hugo@fractalgraphics.com.au>
    Re: email attachment not in body of email using Lite mo (Gwyn Judd)
    Re: File Parsing, Skipping lines (Keith Calvert Ivey)
    Re: Globbing failure (Keith Calvert Ivey)
    Re: Gratuitous incompatibilities (Was: Re: Range operat (Keith Calvert Ivey)
    Re: Gratuitous incompatibilities (Was: Re: Range operat <biow@verity.com>
    Re: Hash creation idiom. <uri@sysarch.com>
    Re: How to Capture Specific Whitespace? <stephenk@cc.gatech.edu>
    Re: Interpolation on the fly (Abigail)
        MD5 Apache Password Encryption? <wrowe@rowe-clan.you.know.why.net>
    Re: Newbie - averages... <ren.maddox@tivoli.com>
    Re: Newbie - averages... (Gwyn Judd)
    Re: Newbie - averages... (Chris Fedde)
        null string circuit_board@my-deja.com
        null string circuit_board@my-deja.com
    Re: null string <philipg@atl.mediaone.net>
    Re: null string <jeff@vpservices.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 22 Sep 2000 03:14:35 GMT
From: robert@goff.com (Robert Goff)
Subject: Re: Accessing Objects in an array
Message-Id: <8qeiqr$950$0@207.66.2.190>

mike_hopkins_us@yahoo.kom (Mike Hopkins) wrote in
<f%ny5.11039$nk3.525913@newsread03.prod.itd.earthlink.net>: 

>Doing this does not work :
>  print $objectArray[2]->param('item'); #Can any one tell me how to do
>  this? 

print ${$objectArray[2]}->param('item');

Better: make $objectArray an array reference, then use

print $objectArray->[2]->param('item');

-- 
Clones are people, two.
===============================================
Robert Goff      beast@avalon.albuquerque.nm.us
Technical Writer/Editor, Webmaster 505-564-8959


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

Date: Thu, 21 Sep 2000 20:49:29 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Accessing Objects in an array
Message-Id: <39CAD6C9.7275F573@vpservices.com>

Robert Goff wrote:
> 
> mike_hopkins_us@yahoo.kom (Mike Hopkins) wrote in
> <f%ny5.11039$nk3.525913@newsread03.prod.itd.earthlink.net>:
> 
> >Doing this does not work :
> >  print $objectArray[2]->param('item'); #Can any one tell me how to do
> >  this?
> 
> print ${$objectArray[2]}->param('item');

Blech!  The OP told us that he had:

> > put several CGI objects into an array.

So @objectArray is an array of CGI objects, not a reference to an array
or an array of references.  His original construct is valid:

	print $objectArray[2]->param('item');

See the example I posted earlier.

> Better: make $objectArray an array reference, then use
> 
> print $objectArray->[2]->param('item');

Why is that better? What he had to begin with was just fine in many
situations.

-- 
Jeff


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

Date: Fri, 22 Sep 2000 00:46:45 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <39caaa9e.2824045@news.newsguy.com>

Larry Rosler <lr@hpl.hp.com> wrote:

>That's why I would never write (as I have seen written here):
>
>    push @array => $value; # UGH!!!
>
>The arrow points the wrong way.

That's why I haven't yet embraced that use of the fat comma.  It
seems inconsistent to avoid it with push() and unshift() but use

it for everything else.  I'd say it points the wrong way 
with pack(), too.  But then if I think so, why don't I feel the
same way about sprintf()?  I suppose it's the name pack().

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 22 Sep 2000 09:01:00 +0200
From: Kai Wipplinger <Kai.Wipplinger@de.bosch.com>
Subject: Re: converting binary string
Message-Id: <39CB03AC.694E4847@de.bosch.com>

Abigail schrieb:

> It would be a good idea to read the documentation that comes with your
> perl, instead of from random source. Then you won't try to do 5.6.0
> semantics on a 5.005 Perl.

It is in the Documentation of activstate Perl 5.005 so i think it should
work.

Greetings

Kai Wipplinger


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

Date: Fri, 22 Sep 2000 04:04:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: CR/LF heritage (was Re: Gratuitous incompatibilities)
Message-Id: <x77l85cbta.fsf_-_@home.sysarch.com>


you all keep forgetting that winblows derived from dos which derived
from cp/m which derived from RT-11. all dec OS's used cr/lf at that time
as crt's were still rare and all printers needed both chars to print
correctly. unix came up with the idea to do that conversion on i/o so
you only needed \n in disk files.

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: Thu, 21 Sep 2000 21:36:01 -0700
From: Bill Karwin <bill@karwin.com>
Subject: Re: creating XS wrapper for C functions inport,inportb,outport,outportb
Message-Id: <39CAE1B1.EBEC2B5@karwin.com>

Josiah Bryan wrote:
> So i have finally given up on compiling XS extensions on Win32...my linux
> box compiles them just fine..(it has perl 5.005_05...btw can i compile XS
> exts on linux and copy to Win32? the bin files prob are incompat, eh?)....

I have written an XS that compiles on Linux, Solaris, and Win32 with
BC++ and MSVC++.  It wasn't easy!  It took several years (off and on)
and help from many other software developers to figure it out (you're
giving up after a few days?  pshaw!  ;-).

Using Borland C++ to link an XS against the ActiveState Perl library is
tricky.  Borland's compiler and Microsoft's compiler don't use the same
 .LIB file format by default.  >:-[  Borland uses OMF, Microsoft prefers
COFF.

Here's what I did: 
1) Start with ActiveState Perl 5.6.0
2) Create an OMF format version of Perl.lib:
   move perl56.lib perl56.lib.ms
   coff2omf perl56.lib.ms perl56.lib
3) Edit Config.pm to use BC++ executables for CC and other programs (see
diffs below)
4) Use dmake, _not_ the make that comes with BC++.

Another caveat:  objects compiled with MSVC++ 5 can't link with objects
compiled with MSVC++ 6, even if they're all COFF format.  Isn't that
special!

My project with a Makefile.PL is at my web site: 
http://www.karwin.com/.  The XS is called IBPerl, it's a Perl binding to
the InterBase RDBMS client API.  Why don't you download it (it's open
source, completely free software) and see if it helps.  There's a form
on the download page, but you can follow a link and get past it if you
don't like to fill out forms.

I hope this helps you get started!

Regards,
Bill Karwin

-----%<------

diff Config.pm.msvc Config.pm.bcc
34c34
< cc='cl'
---
> cc='bcc32'
576c576
< ld='link'
---
> ld='ilink32'
582c582
< libc='msvcrt.lib'
---
> libc='cw32.lib'
606c606
< make='nmake'
---
> make='dmake'
645c645
< optimize='-O1 -MD -DNDEBUG'
---
> optimize='-O1 -DNDEBUG'

-----%<------


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

Date: Thu, 21 Sep 2000 21:22:28 -0400
From: "Neb" <berube@odyssee.net>
Subject: Re: deamonize
Message-Id: <%syy5.245$hs2.11039@news.globetrotter.net>

I can't say actually.  I'm hosted by Hypermart.net and I can't find any
information about their OS version.  How can I get it ?


Philip Garrett <philipg@atl.mediaone.net> a écrit dans le message :
06yy5.1365$2z2.706271@typhoon.southeast.rr.com...
> Neb <berube@odyssee.net> wrote in message
> news:8_sy5.226$hs2.10675@news.globetrotter.net...
> > hi,
> >
> > I got some problem deamonizing a process (child become dissociated from
> > parent) on Unix.  I read "perlipc" and I wrote to this news group but I
> > can't make it work yet.
>
> What flavor of Unix?  The script works as expected on my Linux machine.
>
> p
>
>




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

Date: Fri, 22 Sep 2000 13:19:49 +0600
From: "Konstantin Stupnik" <skv@iis.nsk.su>
Subject: Re: deamonize
Message-Id: <8qetkp$249o$1@nl.novosoft.ru>

Hi!

perldoc -q daemon

Found in d:\Soft\Perl\lib\pod\perlfaq8.pod
  How do I fork a daemon process?

            If by daemon process you mean one that's detached
            (disassociated from its tty), then the following process
            is reported to work on most Unixish systems. Non-Unix
            users should check their Your_OS::Process module for
            other solutions.

    *           Open /dev/tty and use the TIOCNOTTY ioctl on it. See the
                tty(4) manpage for details. Or better yet, you can
                just use the POSIX::setsid() function, so you don't
                have to worry about process groups.

    *           Change directory to /

    *           Reopen STDIN, STDOUT, and STDERR so they're not
                connected to the old tty.

    *           Background yourself like this:

                    fork && exit;

            The Proc::Daemon module, available from CPAN, provides a
            function to perform these actions for you.


--
Best regards,
  Konstantin.
Brainbench MVP for perl.
"Neb" <berube@odyssee.net> wrote in message
news:8_sy5.226$hs2.10675@news.globetrotter.net...
> hi,
>
> I got some problem deamonizing a process (child become dissociated from
> parent) on Unix.  I read "perlipc" and I wrote to this news group but I
> can't make it work yet.
>
> Here is the code:
> ---------------------------------
> use POSIX "setsid";
>
> my $pid = fork;
>
> if( $pid == 0 )
> {
>     if( setsid() == -1 )
>     {
>         print 'Process error.';
>     }
>     sleep(40);
>     print "child";
>     exit(0);
> }
> elsif( undef $pid )
> {
>      print 'Process error.';
> }
> else
> {
>       print 'Parent process.';
> }
> ---------------------------------
>
> The problem with this code: the parent process *still waits* for the child
> process to complete.  But I want the parent process to exit, and the child
> process to continue to live!
>
> What is wrong with my code?
>
> thanks for the help,
>
> neb
>
>
>
>
>




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

Date: Fri, 22 Sep 2000 12:29:47 +0800
From: Hugo Bouckaert <hugo@fractalgraphics.com.au>
Subject: email attachment not in body of email using Lite module 
Message-Id: <39CAE03B.ACB5DEA0@fractalgraphics.com.au>

Hi 

Thanks to several people on this list I eventually got email attachments
to work, when sending data from a form and using a perl script to email
these data. 

One problem remains though: The attachments come up in the body of the
email, not as attachments for which you can (on NT) right-click the
mouse, using the "save this link as" option. 

I had a look at the perldoc Lite documentation, and found something
about using gzip - but that didn't work either. There is something about
"inline" versus "attachments" options, but it is far from clear how to
change that. 
 
At present my perl script contains the following code. If anyone knows
how to change attachments so they do not come up in the body ofthe
email, I would be most grateful. 

****

#!/usr/sbin/perl

#----------------------------------------------------------------------------
# User variables
#----------------------------------------------------------------------------


$emailaddress='hugo@fractalgraphics.com.au';
$thankyoupage='http://www.fractalgraphics.com.au/fracviewer/thanks.html';

use Email;
use CGI qw(:standard);
require Exporter;
use MIME::Lite;

#----------------------------------------------------------------------------
#
# Email response to someone
#
$name= param('Name');
$prod = param('Product');
$att = param('Mdata');
#$attach = upload($att);

$body  = <<MESSAGE_TO_USER;

----------------------------------------------------------------------
          These details were submitted using the WWW Form
            on the Fractal Graphics FracViewer webpage
----------------------------------------------------------------------

Please send information about the requested product to the client's
email address:

Name:          $name
Product:       $prod	

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

MESSAGE_TO_USER

 ### Create a new multipart message:
        $msg = MIME::Lite->build(
                     From    =>'info@fractalgraphics.com.au',
                     To      =>'hugo@fractalgraphics.com.au',
                     Cc      =>'hugo@fractalgraphics.com.au',
                     Subject =>'File Upload procedure',
                     Type    =>'TEXT',
		     Data    =>$body
                    );
$msg->attach(Type     =>'text/html',
	              Content-type =>'attachment',		
                      FH    =>$att
                     );
 
#----------------------------------------------------------------------------
#
# Generate reply for user
#

# Send the thankyou page to the submitter ...

print "Location: $thankyoupage\n\n";

exit;  

****
Any help will be most appreciated. 

Thanks

HUgo 
-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
39 Fairway, Nedlands Western Australia 6009
Tel: 9284 8442
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Fri, 22 Sep 2000 05:18:03 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: email attachment not in body of email using Lite module 
Message-Id: <slrn8slqs3.c5t.tjla@thislove.dyndns.org>

I was shocked! How could Hugo Bouckaert <hugo@fractalgraphics.com.au>
say such a terrible thing:
>Hi 
>
>Thanks to several people on this list I eventually got email attachments
>to work, when sending data from a form and using a perl script to email
>these data. 
>
>One problem remains though: The attachments come up in the body of the
>email, not as attachments for which you can (on NT) right-click the
>mouse, using the "save this link as" option. 

Take a look at the MIME::Lite documentation where it talks about
creating multipart messages. The Type of the message will be
'multipart/mixed' and then you attach whichever bits of data you want.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A tall, dark stranger will have more fun than you.


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

Date: Fri, 22 Sep 2000 01:10:15 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: File Parsing, Skipping lines
Message-Id: <39cbaddc.3654476@news.newsguy.com>

Larry Rosler <lr@hpl.hp.com> wrote:
>Helgi Briem <helgi@NOSPAMdecode.is> says...

>> close BIG,$bigfile or die "Cannot close $bigfile:$!\n";
>
>Interesting.  No warning about the superfluous second argument to 
>close().  Perhaps this is because the first argument is optional (which 
>I wasn't really aware of until I checked it).

It's not a second argument to close(), since close allows only
one argument:

    C:\TEMP>perl -MO=Deparse,-p -e"close BIG,$bigfile or die
    qq(Cannot close $bigfile:$!\n);"
    -e syntax OK
    ((close(BIG), $bigfile) or die("Cannot close
    $bigfile:$!\n"));

If you left off the die() -- which is never executed, assuming
$bigfile is true -- you'd get a warning about "Useless use 
of a private variable in a void context".

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 22 Sep 2000 02:02:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Globbing failure
Message-Id: <39cdbb70.7131126@news.newsguy.com>

"Colin Larcombe" <colin_larcombe@hotmail.com> wrote:

>while( $dailymoodys = <$moodyspath.$moodyswildcard>)  gives me nothing in
>$dailymoodys
>
>but
>
>while( $dailymoodys = <//aim-uk-dc02/download\$/MOODYS/BONDS/*.eod>) does.
>
>Can I not use variables in a glob ?

You can, but it's like using them in double quotes (see perlop).
You don't want that . in between them -- it's in the middle of a
string, so it's not interpreted as the concatenation operator.
If you were using the glob() function instead, you would need
it, though:

    while( $dailymoodys = glob $moodyspath.$moodyswildcard )

You might also want to look into the opendir(), readdir(), and
grep() functions.  A lot of people (including me) prefer them to
globbing, since they allow you to do more complex pattern
matches and file tests in selecting your list of files.  Also,
globbing used to be slow because it required starting up a
separate process, but I think that's been fixed in 5.6.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 22 Sep 2000 01:21:06 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Gratuitous incompatibilities (Was: Re: Range operator with "... /^$/")
Message-Id: <39ccb2b0.4890246@news.newsguy.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
>Christopher Biow wrote:

>>Perhaps LF was chosen for "safety" in that if a file was inadvertantly
>>dumped "raw" to an impact printer, it would not result in a pileup of
>>printing and burn through the paper and platen?
>
>Eh? The default behaviour of LF is to scroll the paper. In addition, CR
>moves the cursor (carriage) to the left edge.

I think you're misinterpreting "pileup of printing" as referring
to paper piling up on the floor, and "burn through the paper" as
referring to using it up.  Notice the word "platen", though.
Christopher seems to mean that using LF would avoid having the
printed words pile up (overwrite) on the same line on the paper
so that the paper was worn through and the platen possibly
damaged (which would be worse than wasting paper).

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 21 Sep 2000 22:58:20 -0400
From: Christopher Biow <biow@verity.com>
Subject: Re: Gratuitous incompatibilities (Was: Re: Range operator with "... /^$/")
Message-Id: <th2lssc0kacm3jnj0tji3d7k89g7i0vjrv@4ax.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
>Christopher Biow wrote:
>>Larry Rosler <lr@hpl.hp.com> wrote:

>>>The Unix use of a single character to represent New Line was clever; the 
>>>use of the character literally implementing Line Feed ("\12") instead of 
>>>an otherwise unused control character led to confusion.  

>>Perhaps LF was chosen for "safety" in that if a file was inadvertantly
>>dumped "raw" to an impact printer, it would not result in a pileup of
>>printing and burn through the paper and platen?

>Eh? The default behaviour of LF is to scroll the paper.

 ...causing ensuing characters to print in a new location, a line below the
previous characters. At worst, this would cause one line's worth of
characters to pile up at the printer's rightmost column, though the PC
printers that I can recall would wrap-around to the next line in the event
of a right-side overflow.

> In addition, CR moves the cursor (carriage) to the left edge.

 ...causing ensuing characters to print in the same location as the previous
line. A thousand-line document would therefore appear with all thousand
lines superimposed, burning through the paper and possibly damaging the
platen.

>>>Apple's choice of Carriage Return ("\15") for the same logical function 
>>>compounded the confusion.

>>*Not* safe in that respect!

>Oh yes it is. in raw mode, CR never moves to the next line.

Exactly, so each succeeding line of output prints on the same physical line
of paper.

>Anyway, it is pretty much the same as the discussion of big-endian vs.
>little endian number representation: none is superior. It's just a
>choice.

Agreed. In this case, the options may have had distinct pros and cons, with
the choices made possibly each being correct for their respective markets.
But it leaves DOS-lineage systems with yet another kludge (under the bodge
(beneath the jury-rig)) that adds internal and cross-platform complexity.

ObPerl: ...and cross-platform languages.


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

Date: Fri, 22 Sep 2000 02:56:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hash creation idiom.
Message-Id: <x7d7hxcexb.fsf@home.sysarch.com>

>>>>> "ADD" == Arthur Darren Dunham <add@netcom.com> writes:

  ADD> # array and x
  ADD> @items = qw ( red rose chair )
  ADD> @items{@items} = ( 1 x scalar(@items));

i use this. no need for the scalar. if all you care is whether a key is
in the hash and you test with exists, you can just assign ()

	@items{@items} = () ;

	if ( exists( $items{ $foo } ) .....

  ADD> # array and map
  ADD> @items = qw ( red rose chair )
  ADD> @items{@items} = map { 1 } @items;

that is odd. the map will probably be slower than the x version above.
a more common idiom with map is:

	%items = map { $_ => 1 } @items;

  ADD> # foreach
  ADD> @items = qw ( red rose chair )
  ADD> foreach ( @items )
  ADD> { $items{$_} = 1; }

probably the slowest and definitely the longest code. not very
idiomatic.

BTW choosing the same name for the array and hash looks cute but is very
poor coding style. for hashes used to test things i would call it
%is_an_item

see my hash slice tutorial on my site or at perlarchive.com for much
more on these ideas.

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: Thu, 21 Sep 2000 23:14:23 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: How to Capture Specific Whitespace?
Message-Id: <39CACE8E.620F1D66@cc.gatech.edu>

beach9000@hotmail.com wrote:

> Thanks for all your help,
>
> But here's one more case that I'm curious about: how would you capture
> the whitespace before EACH instance of the markertext on the SAME line?
>
> For instance:
>
> [sol]   markertext blah     markertext blah [...] blahmarkertext[eol]
>
> so that
>
>    markertext 1 = 3
>    markertext 2 = 5
>    ...
>    markertext n = 0
>
> where markertext is the same keyword found throughout the line.
>
> My first guess would be to use previous posted split example, and try to
> figure out the index of the markertext.  After that, I could just grab
> the space in the preceding cell, but I'd like to here other suggestions.
>
> Thanks
>

Use a global match.  $string =~ /(\s*)$marker/g will return an array of
every occurence of 0 more whitespace characters preceding $marker.  Since
you want numbers, not spaces, use the map and length functions to return an
array of string lengths:
@spaces = map length,$string=~/(\s*)$marker/g;

perldoc perlre
perldoc perlop
perldoc -f map
perldoc -f length

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: 22 Sep 2000 01:24:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Interpolation on the fly
Message-Id: <slrn8sld42.5fq.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@verbruggen.comdyn.com.au) wrote on MMDLXXVIII
September MCMXCIII in <URL:news:slrn8sl1i4.m9.mgjv@verbruggen.comdyn.com.au>:
 .. On 21 Sep 2000 03:55:57 GMT,
 .. 	Abigail <abigail@foad.org> wrote:
 .. 
 .. > But it doesn't do "late" interpolation of arrays.
 .. 
 .. If you can make that work, I think it would be a very valuable
 .. addition to CPAN.


I don't think I can. Perl isn't handing a reference to the array to any
of the overload subs, AFAIK; it's doing a C<join $" => @array> first, 
and using the result of that.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 22 Sep 2000 04:06:43 GMT
From: "William A. Rowe, Jr." <wrowe@rowe-clan.you.know.why.net>
Subject: MD5 Apache Password Encryption?
Message-Id: <8qelsj$k91@dispatch.concentric.net>

I'm thoroughly lost... please help.

Does anyone have an example of how to 'seed' MD5 or Digest::MD5
for password encryption?  crypt() is useless in this specific situation,
so I must use MD5 encryption.

Or is there another package I aught to be looking for?

Bill




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

Date: 21 Sep 2000 18:42:06 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Newbie - averages...
Message-Id: <m3aed1tir5.fsf@dhcp11-177.support.tivoli.com>

"Nicolas MONNET" <nico@monnet.to> writes:

> What the fuck was Yanick Champoux <yanick@babyl.sympatico.ca> trying to
> say:
> 
> > 	perl -ne'$\+=$_;END{$\/=$.;print}' your_file
> 
> [nico@nico nico]$ touch your_file
> [nico@nico nico]$ perl -ne'$\+=$_;END{$\/=$.;print}' your_file
> Illegal division by zero at -e line 1.
> END failed--call queue aborted.
> [nico@nico nico]$

perl -lne'END{print$*}(($**=$.-1)+=$_)/=$.'

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 22 Sep 2000 01:48:50 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Newbie - averages...
Message-Id: <slrn8slejr.b9b.tjla@thislove.dyndns.org>

I was shocked! How could Larry Rosler <lr@hpl.hp.com>
say such a terrible thing:

># sans Perl magic mojo (completely):
>
>#!/usr/bin/perl -wl
>use strict;
>
>sub average {
>    my $sum;
>    $sum += $_ for @_;
>    @_ ? $sum/@_ : undef
>}
>
>print average(<DATA>);

I'm surprised nobody has mentioned what may be the most efficient
version:

#!/usr/bin/perl -w
use strict;
use Benchmark;
use List::Util qw(sum);

sub ave(@)
{
    my $sum;
    foreach(@_)
    {
        $sum += $_;
    }

    $sum/@_;
}

sub average(@)
{
    (sum @_)/@_
}

timethese (1 << 6, {
    'ave' => 'ave 1..100000',
    'average' => 'average 1..100000',
});

Since the List::Util version is compiled C code (on some machines anyway
it is likely to be much quicker).

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)

"Curse my metal pants, I wasn't fast enough!" --Threepio

"Star Wars A New Hope (tm)", "Pants" Style


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

Date: Fri, 22 Sep 2000 03:58:59 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Newbie - averages...
Message-Id: <7OAy5.328$W3.189941248@news.frii.net>

In article <5f0lssont2cfmqnug556jn6t95n21668ar@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>ian_tait@my-deja.com wrote:
>
>>What I'm trying to do is to open a text file (I
>>can do this bit :-) that contains a column of
>>numbers eg,
>>
>
> sub sum {
>     my $sum = shift || 0;
>     $sum += $_ foreach @_;
>     $sum;
> }
> sub average {
>     sum(@_)/@_;
> }
> print average(grep { /\d/ } <DATA>);
># Trailing newlines don't hurt.
>__DATA__
>33
>33
>44
>55
>	    

Do you have kids?  Have you ever read a book called _If you give a Mouse a
Cookie_?  Cute book... 

If you give a mouse some numbers he'll probably want the mean.
If you give a mouse the mean he'll probably want a deviation.
If you give a mouse a deviation he'll probably want a score....

Barring the admirable quest for a better golf handicap, Skip all this
and go straight to Statistics::Descriptive.

chris
--
If You Give a Mouse a Cookie
    -- Felicia Bond(Illustrator), Laura Joffe Numeroff
-- 
    This space intentionally left blank


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

Date: Fri, 22 Sep 2000 05:02:27 GMT
From: circuit_board@my-deja.com
Subject: null string
Message-Id: <8qep4r$p0c$1@nnrp1.deja.com>

I have looked absolutely everywhere to try to find an answer to this.
All I'm trying to do is to see if $somestring is null. I have tried /\s/
but this matches a space not null. I have tried " ", ' ' but none of
these work. How do I test if($somestring = null) ? Thanks for your help.


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


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

Date: Fri, 22 Sep 2000 05:31:51 GMT
From: circuit_board@my-deja.com
Subject: null string
Message-Id: <8qeqs7$qr2$1@nnrp1.deja.com>

Finally got it. Trick is don't have a space in between the single quote.

If ($somestring eq '')  blah blah blah.


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


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

Date: Fri, 22 Sep 2000 05:11:58 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: null string
Message-Id: <ySBy5.2016$2z2.863535@typhoon.southeast.rr.com>

<circuit_board@my-deja.com> wrote in message
news:8qep4r$p0c$1@nnrp1.deja.com...
> I have looked absolutely everywhere to try to find an answer to this.
> All I'm trying to do is to see if $somestring is null. I have tried /\s/
> but this matches a space not null. I have tried " ", ' ' but none of
> these work. How do I test if($somestring = null) ? Thanks for your help.

if ($somestring eq '') { ... }

hth,
p




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

Date: Thu, 21 Sep 2000 22:44:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: null string
Message-Id: <39CAF1A0.B82330FA@vpservices.com>

circuit_board@my-deja.com wrote:
> 
> Finally got it. Trick is don't have a space in between the single quote.
> 
> If ($somestring eq '')  blah blah blah.

That works.  Or if you don't care about the difference between an empty
string, 0, and an undefined variable (all of which are treated as
"false"), then you can say:

if( !$something ) { ... }

or

unless ( $something ) { ... }

-- 
Jeff


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

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


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