[10885] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4486 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 23 11:07:40 1998

Date: Wed, 23 Dec 98 08:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 Dec 1998     Volume: 8 Number: 4486

Today's topics:
    Re: $&, $', and $` and parens.... (Bart Lateur)
        ADO cade@acm.org
    Re: Apache httpd needs perl? wrong @INC <sevo@inm.de>
    Re: Big-Endian to Little-Endian <tlynch@cisco.com>
    Re: Big-Endian to Little-Endian (Steffen Beyer)
    Re: Big-Endian to Little-Endian (Micha3 Rutka)
        Looking for perl for NT with Curses <enaiman@ndsisrael.com>
    Re: NEWBIE:  $_ (Bart Lateur)
    Re: NEWBIE:  $_ <newsposter@cthulhu.demon.nl>
        NT 4.0 Linking Problems unxgroup@nyct.net
    Re: numbers in base 36 droby@copyright.com
    Re: Perl and As400 <steve@grantps.net>
        Perldoc problem w. Perl for Win32 (Robert Watkins)
    Re: Please help me reading .csv textfiles (Bart Lateur)
    Re: print one pixel gif w/ perl <Paul.Makepeace@POBox.com>
    Re: Real Newbie--please help <carvdawg@patriot.net>
    Re: Real Newbie--please help (Larry Rosler)
    Re: replacement question (Clay Irving)
    Re: scoped references (Andrew M. Langmead)
    Re: sizeof() function? (Andrew M. Langmead)
    Re: Socket Initialize error (Andrew M. Langmead)
    Re: sort it ? (Micha3 Rutka)
    Re: sort it ? (Larry Rosler)
    Re: Turning Variables into CAPS? <rick.delaney@home.com>
    Re: What's wrong with this code? <newsposter@cthulhu.demon.nl>
        Where can you get undump <gary.w.propp@cdc.com>
        while (<>) and $!\n (Joergen W. Lang)
    Re: while (<>) and $!\n <jamesht@idt.net>
    Re: while (<>) and $!\n <jamesht@idt.net>
    Re: Win Port - AWK to Perl conversion <jlcrosby@fwi.com>
    Re: Win Port - AWK to Perl conversion (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 23 Dec 1998 12:58:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $&, $', and $` and parens....
Message-Id: <3683e778.3644438@news.skynet.be>

Bart Lateur wrote:

>Look, if you really want to get rid of $&, $` and $', here's one way to
>do it:

Here's another way. It doesn't work if you have internal parentheses as
well.

	$_ = ",;:abc&#^def***";
	($before,$match,$after) = split /(\w+)/,$_,2;
	print "Before: $before\nMatch: $match\nAfter: $after\n";

Result:
	Before: ,;:
	Match: abc
	After: &#^def***

	Bart.


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

Date: Wed, 23 Dec 1998 15:29:24 GMT
From: cade@acm.org
Subject: ADO
Message-Id: <75r28h$jol$1@nnrp1.dejanews.com>

I get the following error:

Can't modify subroutine entry in scalar assignment, at EOF

The problem line is the one which sets the value.  I have no trouble
extracting values from an existing recordset, but when attempting to add
records and update the fields I get this.  I can add empty records with no
problem! (i.e. the ->AddNew() and ->Update() are working fine.)  FWIW, the
script is hosted by Windows Scripting Host if that's any issue.

use Net::POP3 ;
use Win32::ADO ;

$Conn = $WScript->CreateObject("ADODB.Connection") ; $RS =
$WScript->CreateObject("ADODB.Recordset") ;
$Conn->Open("DBQ=test.mdb;DefaultDir=.;Driver={Microsoft Access Driver
(*.mdb)};DriverId=25;FIL=MS
Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;S
afe Transactions=0;Threads=3;UID=admin;UserCommitSync=Yes;", "admin", "") ;
$Conn->Execute("DELETE * FROM test") ; $RS->Open("SELECT FIELD1 FROM Test",
$Conn, adLockOptimistic, adOpenDynamic) ;

$RS->AddNew() ;
$RS->Fields("FIELD1")->Value = "test" ;
$RS->Update() ;

$RS->Close() ;
$Conn->Close() ;

$WScript->Echo("All Done") ;

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


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

Date: Mon, 21 Dec 1998 11:55:25 +0100
From: Sevo Stille <sevo@inm.de>
Subject: Re: Apache httpd needs perl? wrong @INC
Message-Id: <367E291D.561F2A97@inm.de>

otis@my-dejanews.com wrote:

> My questions are:
> 1. why does Apache httpd even need perl in the first place?
>    I looked at all 3 .conf files and there is only one place where perl is
> mentioned and that part is commented out

Presumably because you did not build apache, but used that disgusting
RPM mechanism to install a prebuilt binary which obviously contains
mod_perl. 

> 2. the @INC that is listed above is wrong - perl -V gives me different
> directories. Why does this httpd have the wrong @INC?  How do I tell it where
> to look instead?

Preferrably not at all - manually forcing the embedded perl 5.004 to use
the 5.005 modules will sooner or later break something. Build apache
without mod_perl if you don't need it, or build it with the same perl
version you use otherwise on your machine.

Sevo  

-- 
Sevo Stille
sevo@inm.de


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

Date: Wed, 23 Dec 1998 08:08:23 -0500
From: Tom Lynch <tlynch@cisco.com>
To: "Micha3 Rutka" <rutka@lucent.com>
Subject: Re: Big-Endian to Little-Endian
Message-Id: <3680EB47.6F46344C@cisco.com>

Hi:

	Thanks that was it. I goofed on the orginal
	mail I ment to say "0x163b000" missing a 
	zero there.

	Thanks Again
	  Tom

Micha3 Rutka wrote:
> 
> But ..., it will give you 68dc0100 as result, not 163b800. Maybe, what you
> want is also swap bit-order (i.e. MSB <-> LSB, etc). The code below
> will do almost what you want:
> 
> $little = (unpack ('V', pack('b*',(unpack('B*',(pack('N', hex($ARGV[0]))))))));
> printf ("%x\n",$little);
> 
> Uff. Lot of conversions here ;-). You can try to optimize it
> somehow. If you do it, please send me a code.
> 
> I said, 'almost' because the result is now 163b8000 and not 163b800,
> as you wanted.

-- 
#-----------------------+--------------------------+
# Tom Lynch             | Email: tlynch@cisco.com  |
# Cisco Systems         | Phone: 978-244-8765      | 
# 250 Apollo Drive      | FAX:   978-244-8039      |
# Chelmsford MA 01824   | MS:    CH1-2LF           |
#-----------------------+--------------------------+


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

Date: 23 Dec 1998 13:19:09 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Big-Endian to Little-Endian
Message-Id: <75qqkd$583$1@en1.engelschall.com>

Micha3 Rutka <rutka@lucent.com> wrote:

> But ..., it will give you 68dc0100 as result, not 163b800. Maybe, what you
> want is also swap bit-order (i.e. MSB <-> LSB, etc). The code below
> will do almost what you want:

> $little = (unpack ('V', pack('b*',(unpack('B*',(pack('N', hex($ARGV[0]))))))));
> printf ("%x\n",$little);

> Uff. Lot of conversions here ;-). You can try to optimize it
> somehow. If you do it, please send me a code.

The module Bit::Vector has a built-in method for reversing bit-order...

And the module is internally written in C...

See below for URLs where to find it...

HTH.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/download/    (Free Perl and C Software
    http://www.perl.com/CPAN/authors/id/STBEY/         for Download)
    http://www.oreilly.de/catalog/perlmodger/bnp.html
    New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)


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

Date: 23 Dec 1998 15:23:19 +0100
From: rutka@lucent.com (Micha3 Rutka)
Subject: Re: Big-Endian to Little-Endian
Message-Id: <wsm1zlr544o.fsf@hzsac328.nl.lucent.com>

sb@engelschall.com (Steffen Beyer) writes:
> The module Bit::Vector has a built-in method for reversing bit-order...
> 
> And the module is internally written in C...

The funny thing is that I know and use Bit::Vector! I just forgot it
for a while because I am too much in pack/unpack stuff nowdays
:-). Anyway, thx for info, and I have to admit that I like Bit::Vector 
(together with other your stuff) very much.

Best wishes,
-- 
Dr. Ir. Michal Rutka       Lucent Technologies - Huizen, The Netherlands
Senior System Engineer     mailto:rutka@lucent.com


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

Date: Wed, 23 Dec 1998 16:52:49 +0200
From: "Ephrayim \"EJ\" Naiman" <enaiman@ndsisrael.com>
Subject: Looking for perl for NT with Curses
Message-Id: <75r04e$1nb$1@news.netvision.net.il>

I've searched dejanews and the CPAN/ActiveState's sites and can't find
it anywhere.  If you where I can get perl with curses for NT, please
drop me email.

Thanx,

Ephrayim "EJ" Naiman
NDS Technologies Israel Limited
enaiman@ndsisrael.com





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

Date: Wed, 23 Dec 1998 13:06:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: NEWBIE:  $_
Message-Id: <3685ea73.4407511@news.skynet.be>

Helen van Niekerk wrote:

>while(<$filename>)
^^^^????
>{
>   print EML $_;
>}
>close(EML);
>
>And it works fine for the first 10.  The next 10 people get an empty email
>as we now have our file pointer at the bottom of the file. Correct?

No. I suspect that either $filename must contain a handle for a file
that is opened (similar to "EML"), or else you might get the result of a
glob. Reading a file using <$filename> does not work, AFAIK.

	Bart.


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

Date: Wed, 23 Dec 1998 09:48:58 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: NEWBIE:  $_
Message-Id: <368102DA.C82BC8A3@cthulhu.demon.nl>

Helen van Niekerk wrote:
> 
> Hi
> I am using a perl script to upload a file to our Web server and then to mail
> the file to the subscribers of our mailing list.
> 
> I read 10 email addresses into eml and then call the following bit of code:
> ( where filename is the name of the uploaded file.
> 
> open(EML, "|fastmail -f DCD -F editor\@dso.pwv.gov.za -s Newsletter - $eml
> ");
> while(<$filename>)
> {
>    print EML $_;
> }
> close(EML);
> 
> And it works fine for the first 10.  The next 10 people get an empty email
> as we now have our file pointer at the bottom of the file. Correct?
> 
> How do I reset the file pointer without explicitly opening and closing this
> file. ( Have tried that one - and nobody got anything! )

Read the entire contents of the file in a variable, then use 'print EML $var;'.

Btw, next time choose a more appropriate subject.

Erik
-- 
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely.  And everyone who owns a car intends that it be used as a
portable dumpster.  Any unwanted garbage in their vehicle they can
simply throw away, after all.


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

Date: Wed, 23 Dec 1998 15:35:41 GMT
From: unxgroup@nyct.net
Subject: NT 4.0 Linking Problems
Message-Id: <75r2kd$jvu$1@nnrp1.dejanews.com>

I am having trouble successfully linking an embedded Perl C++ (MS 5.0)
routine when I added code to push arguments onto the Perl stack.  I've
read all I can find, tried adding in all libs used to compile Perl and
still have unresolved refs as follows:

Linking...
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
int __cdecl win32_printf(char const *,...)" (__imp_?win32_printf@@YAHPBDZZ)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
struct sv *  Perl_Sv" (__imp_?Perl_Sv@@3PAUsv@@A)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
struct sv * *  Perl_stack_max" (__imp_?Perl_stack_max@@3PAPAUsv@@A)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
struct sv * *  Perl_stack_base" (__imp_?Perl_stack_base@@3PAPAUsv@@A)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
long *  Perl_markstack_max" (__imp_?Perl_markstack_max@@3PAJA)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
long *  Perl_markstack_ptr" (__imp_?Perl_markstack_ptr@@3PAJA)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
long  Perl_tmps_ix" (__imp_?Perl_tmps_ix@@3JA)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
long  Perl_tmps_floor" (__imp_?Perl_tmps_floor@@3JA)
broker.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
struct sv * *  Perl_stack_sp" (__imp_?Perl_stack_sp@@3PAPAUsv@@A)
Debug/Broker.exe : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.


Thanks for the help!

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


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

Date: Wed, 23 Dec 1998 14:24:57 GMT
From: droby@copyright.com
Subject: Re: numbers in base 36
Message-Id: <75qufm$g9j$1@nnrp1.dejanews.com>

In article <75ptf6$cro$1@client3.news.psi.net>,
  abigail@fnx.com wrote:
> ++ >
> ++ > [ 55 line solution deleted ]
> ++ >
> ++ > Here's a one liner, with no need for Perl:
> ++ >
> ++ > $ echo "obase = 789; 123 ^ 456" | bc
> ++
> ++ Cheating!  My original question wanted the answer in Java.  Somebody
> ++ said "Java" and "in any base"...
>
> I guess you can use some kind of pipe object in Java and communicate
> with bc.
>
> But that wouldn't be a one liner any more. And I love one liners.
>

I love your one liners too, Abigail!  At least the Perl ones.

But my 55-line method (that count includes space and comments, btw) could
probably be translated into 100%-pure Java pretty easily, since it's
basically C style Perl...  Might have to implement a BigInt class in Java
first.	Not being a Java programmer, I'll skip it.  Also it would probably
end up much more than 55 lines, and I'm already sufficiently inefficient.


--
Don Roby
droby@copyright.com

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


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

Date: 23 Dec 1998 10:27:07 -0500
From: "Steve Swett" <steve@grantps.net>
Subject: Re: Perl and As400
Message-Id: <01be2e8b$d9bb1180$21e6b0c7@techdir.grantps.net>

I'm a rookie, too, as I've just loaded Perl on the AS/400 today.  However,
I was able to get a very simple script to run.

First, you may want to use the perlrisc.savf instead of the perlpgm.savf. 
The former is for a V4R1 (RISC) machine, the latter for a CISC machine.

Secondly, did you actually write a CL program containing the "call"
statement, or are you trying to run that from a command line?  You should
write a CL program and then start that CL program from a web browser.

How do you do that?  Following is a sample URL that calls a CL program
named HELLOSTEVE in a library named CGIBIN:

http://MYAS400/QSYS.LIB/LIBRARY.LIB/HELLOSTEVE.PGM

You might ask, how does it get to library CGIBIN based on that?  That's
determined by the directives in the HTTP server configuration on the
AS/400.  Following is an example:

EXEC  /QSYS.LIB/LIBRARY.LIB/*  /QSYS.LIB/CGIBIN.LIB/*

This was added to the entries shown when using the AS/400 command
WRKHTTPCFG.

You may want to go to the IBM AS/400 Technical Studio on-line and go
through the topics of HTTP server configuration and preparation for running
a sample Net.Data script (which is a Perl alternative).  You'll learn a few
general tips from that.


Len <len@buffnet.net> wrote in article <367fe457.0@news3.buffnet.net>...
> I've recently restored object perlpgm.savf file to a V4R1 As400. While
> trying to execute "call pgm(perl5/perl)  parm('/QopenSys/test.pl')  got
the
> following error "Cannot resolve to object QCPA, type and subtype x'0401'
and
> authority x'0000' " . Got a suggestion about restoring object
persrc.savf,
> but there's no ILE/C compiler on the machine.
> Does anyone have any ideas or help to get me started with Perl5 on the
> As400?
> 
> 
> 
> 
> 


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

Date: 23 Dec 1998 15:29:32 GMT
From: r-watkins@worldnet.att.net (Robert Watkins)
Subject: Perldoc problem w. Perl for Win32
Message-Id: <75r28s$4m7@bgtnsc02.worldnet.att.net>

I was using the stadard port of Perl on my NT box, and had no problems. Now, 
after having installed ActiveState's Perl for Win32 from the Perl Resource Kit 
Win32 Edition, perldoc acts strangely.

C:> perldoc perlsyn
produces no output in the NT command shell.

C:> perldoc -v perlsyn
shows the path searched and tells me where the .pod file was found 
(referred to below as <path>) but does not produce any output.

C:> perldoc perlsyn > perlsyn.txt
creates a text file with the pod data neatly formatted as one would have 
expected it in the shell.

C:> perldoc -f map
returns: Can't start filter at !Script at line 403, <PFUNC> chunk 2068

Line 403 of perldoc.bat is:
open (FORMATTER, "| pod2text") || die "Can't start filter";

but
C:> pod2text <path>\perlsyn.pod
produces the output I would have expected from "perldoc perlsyn"

Any suggestions?

--------------------------------
Robert Watkins
r-watkinsNO@SPAMworldnet.att.net
--------------------------------


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

Date: Wed, 23 Dec 1998 13:24:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Please help me reading .csv textfiles
Message-Id: <3680eea1.5477395@news.skynet.be>

Martien Verbruggen wrote:

>#!/usr/local/bin/perl5.00404 -w
>use strict;
>use Text::ParseWords;
>
>while (<DATA>)
>{
>	chomp;
>	my @words = quotewords(',', 1, $_);
>
>	print join(" : ", @words),"\n";
>}
>
>__DATA__
>"field1","field2 has "quotes" in it",field 3,"field 4"
>
>__OUTPUT__
>"field1" : "field2 has "quotes" in it" : field 3 : "field 4"

That doesn't seem right. What would you do with a '",' sequence?

The ordinary approach seems to be to double the quotes, so the output
should be:

"field1" : "field2 has ""quotes"" in it" : field 3 : "field 4"

	Bart.


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

Date: Wed, 23 Dec 1998 13:12:04 -0000
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: print one pixel gif w/ perl
Message-Id: <75qqcl$2n4$1@statler.server.colt.net>

[ Cc: mailed to original poster ]

Oliver Moffat wrote in message ...
>I'm building a web site access statistics script with perl. My isp dosen't
>allow ssi so I'm using a single pixel trick to call the script.
>
>I stole this sub routine from the AXS Script Set, Logging Module, Version
>2.01 by Fluid Dynamics http://www.xav.com/scripts/axs, but the pixel is
>NOT transparent. I don't know how it works and so don't know how to fix
>it. Specificly, what I don't understand is the actual list of bytes, are
>they correct? Or is there a better way to do this?
>
>
>
>sub Print_Image
>{
>$| = 1;
>@Binary_Code = (71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,
>   33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,1,1,50,0,59);


$ perl -MCPAN -e 'install "GD"'
$ perl -MGD -e '$i = new GD::Image(1,1); $i->transparent($w =
$i->colorAllocate(0,0,0)); $i->setPixel(0,0,$w);
print "\@bc = (",(join ", ", map {ord} split //, $i->gif),");\n"'
@bc = (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 33,
249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
$

(Missing the setPixel gave the same result, FWIW)

If all else fails you could of course just do:

# Make sure binmode GIF is used where appropriate.
open GIF,
"single_pixel_gif_i_snarfed_off_a_site_out_of_my_browser_cache.gif";
print while <GIF>;
close GIF;

Paul

--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo






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

Date: Wed, 23 Dec 1998 09:08:55 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Real Newbie--please help
Message-Id: <3680B327.53E88B9A@patriot.net>

I can easily see why no one won the "Perl as a first programming language"
war...whatever that is...with responses like these...

> This is the only thing that annoys you about Win95??
> Seriously now, I can think of two remedies:
>
> 1) Use the shebanh line at the beginning of your source code. For unix
> systems, that's usually:
>
>         #!/usr/bin/perl -w
>
> or something like that. I'm not sure about Windows, but have a look at
> 'perldoc perlrun'. It should contain the solution.
>

Interesting how the "experts" respond.  Look, don't get me wrong...I do
greatlyappreciate the fact that ANYONE takes the time to respond at all, but
this
response is just so far off base it isn't even funny.  What you'll end up
doing is
frustrating the poor girl into becoming a Perl-hater...

Windows DOES NOT parse the shebang...it treats it like just another comment
line.





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

Date: Wed, 23 Dec 1998 07:11:38 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Real Newbie--please help
Message-Id: <MPG.10eaa808a9ffa6989972@nntp.hpl.hp.com>

In article <3680B327.53E88B9A@patriot.net> on Wed, 23 Dec 1998 09:08:55 
+0000, Marquis de Carvdawg <carvdawg@patriot.net> says...
 ... 
> Windows DOES NOT parse the shebang...it treats it like just another comment
> line.

WRONG!  It ignores the path, but parses the flags (such as '-w'), if 
any.

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


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

Date: 23 Dec 1998 09:47:51 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: replacement question
Message-Id: <75qvqn$m9o@panix.com>

In <3680A95D.4F193EED@mailexcite.com> me <groans@mailexcite.com> writes:

>>>Thanks for responding.  I have not had too much success with LWP and the
>>>modules(each time my script references one, it says that the module needs
>>>other modules.  When I put them where they are supposed to be, it tells
>>>me I need even more.  SOme I have not been able to find, so I just gave up).
>>>Perhaps I will take this time to revisit them . . . Thanks again!

>> Next time you revisit them, use the CPAN module (included in the Perl
>> distribution) to install other modules -- You'll be happier for it. :)

>What makes it better?  I should know this but I don't because I have had bad
>experiences with modules and have not used them . . .

It makes life simple. :)

It automates the process of finding modules, installing them, updating them, 
and bundling them.  Look at the first few paragraphs of the documentation 
for the CPAN module:
   
   NAME
       CPAN - query, download and build perl modules from CPAN sites
   
   SYNOPSIS
       Interactive mode:
   
         perl -MCPAN -e shell;
   
       Batch mode:
   
         use CPAN;
   
         autobundle, clean, install, make, recompile, test
   
   DESCRIPTION
       The CPAN module is designed to automate the make and install of
       perl modules and extensions. It includes some searching
       capabilities and knows how to use Net::FTP or LWP (or lynx or an
       external ftp client) to fetch the raw data from the net.
   
       Modules are fetched from one or more of the mirrored CPAN
       (Comprehensive Perl Archive Network) sites and unpacked in a
       dedicated directory.
   
       The CPAN module also supports the concept of named and versioned
       'bundles' of modules. Bundles simplify the handling of sets of
       related modules. See BUNDLES below.
   
       The package contains a session manager and a cache manager.
       There is no status retained between sessions. The session
       manager keeps track of what has been fetched, built and
       installed in the current session. The cache manager keeps track
       of the disk space occupied by the make processes and deletes
       excess space according to a simple FIFO mechanism.
   
       For extended searching capabilities there's a plugin for CPAN
       available, the CPAN::WAIT manpage. `CPAN::WAIT' is a full-text
       search engine that indexes all documents available in CPAN
       authors directories. If `CPAN::WAIT' is installed on your
       system, the interactive shell of <CPAN.pm> will enable the `wq',
       `wr', `wd', `wl', and `wh' commands which send queries to the
       WAIT server that has been configured for your installation.
   
       All other methods provided are accessible in a programmer style
       and in an interactive shell style.
[...]   
   
Here, I'll give you an example. I'll install the File::Tail module which
has a prerequisite Time::HiRes module. 
   
   # perl -MCPAN -e shell
   
   cpan shell -- CPAN exploration and modules installation (v1.43)
   ReadLine support enabled
   
Install the File::Tail module:

   cpan> install File::Tail
   Running make for MGRABNAR/File-Tail-0.85.tar.gz
   Fetching with LWP:
     ftp://ftp.cdrom.com/pub/perl/CPAN/authors/id/MGRABNAR/File-Tail-0.85.tar.gz
   CPAN: MD5 loaded ok
   Fetching with LWP:
     ftp://ftp.cdrom.com/pub/perl/CPAN/authors/id/MGRABNAR/CHECKSUMS
   Checksum for /net/local/src/CPAN/sources/authors/id/MGRABNAR/File-Tail-0.85.tar.
   gz ok
   x File-Tail-0.85, 0 bytes, 0 tape blocks
   x File-Tail-0.85/t, 0 bytes, 0 tape blocks
   x File-Tail-0.85/t/10open.t, 1653 bytes, 4 tape blocks
   x File-Tail-0.85/t/20tail.t, 1931 bytes, 4 tape blocks
   x File-Tail-0.85/Makefile.PL, 1440 bytes, 3 tape blocks
   x File-Tail-0.85/logwatch, 1391 bytes, 3 tape blocks
   x File-Tail-0.85/Changes, 1404 bytes, 3 tape blocks
   x File-Tail-0.85/test.pl, 361 bytes, 1 tape blocks
   x File-Tail-0.85/Tail.pm, 17741 bytes, 35 tape blocks
   x File-Tail-0.85/README, 1392 bytes, 3 tape blocks
   x File-Tail-0.85/MANIFEST, 82 bytes, 1 tape blocks
   
     CPAN.pm: Going to build MGRABNAR/File-Tail-0.85.tar.gz
   
   Checking for FileHandle...ok
   Checking for File::stat...ok
   Checking for IO::Seekable...ok

Oops! Time::HiRes is a prerequisite:

   Checking for Time::HiRes... not found
   To install this module, you will need the Time::HiRes module,
   version 1.12 or later,
   available from CPAN/modules/by-module/Time/Time-HiRes-x.x.tar.gz
   Running make test
     Make had some problems, maybe interrupted? Won't test
   Running make install
     Make had some problems, maybe interrupted? Won't install
   
No problem... Just install the Time::HiRes module:

   cpan> install Time::HiRes
   Running make for DEWEG/Time-HiRes-01.19.tar.gz
   Fetching with LWP:
     ftp://ftp.cdrom.com/pub/perl/CPAN/authors/id/DEWEG/Time-HiRes-01.19.tar.gz
   Fetching with LWP:
     ftp://ftp.cdrom.com/pub/perl/CPAN/authors/id/DEWEG/CHECKSUMS
   Checksum for /net/local/src/CPAN/sources/authors/id/DEWEG/Time-HiRes-01.19.tar.g
   z ok
   x Time-HiRes-01.19, 0 bytes, 0 tape blocks
   x Time-HiRes-01.19/Makefile.PL, 4991 bytes, 10 tape blocks
   x Time-HiRes-01.19/t, 0 bytes, 0 tape blocks
   x Time-HiRes-01.19/t/02export.t, 1374 bytes, 3 tape blocks
   x Time-HiRes-01.19/t/01test.t, 3254 bytes, 7 tape blocks
   x Time-HiRes-01.19/Changes, 3397 bytes, 7 tape blocks
   x Time-HiRes-01.19/HiRes.xs, 5358 bytes, 11 tape blocks
   x Time-HiRes-01.19/HiRes.pm, 6453 bytes, 13 tape blocks
   x Time-HiRes-01.19/TODO, 40 bytes, 1 tape blocks
   x Time-HiRes-01.19/README, 1738 bytes, 4 tape blocks
   x Time-HiRes-01.19/MANIFEST, 83 bytes, 1 tape blocks
   
     CPAN.pm: Going to build DEWEG/Time-HiRes-01.19.tar.gz

[ remainder of the dialog omitted...]

Do you get the picture now?    

-- 
Clay Irving
clay@panix.com


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

Date: Wed, 23 Dec 1998 15:04:59 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: scoped references
Message-Id: <F4FB8B.Fr5@world.std.com>

Ruben I Safir <ruben@llinderman.dental.nyu.edu> writes:

>I want to make sure the entire data structure disapears from memory
>after
>the subroutine ends.  Thus, if I call the the subroutine again, it
>starts empty.

There are two different issues here. One is completely a non-issue,
the other is unlikely to be one.

If the hash is lexically scoped to the subroutine (a private, or my()
variable) it will go out of scope when the subroutine ends, and will
start empty the next time through.

If there are no other references to the embedded data when the top
level hash goes out of scope, perl will notice that no one needs the
data any more and will delete it. If you create a another reference to
the data and store it someplace that doesn't go out of scope when the
subroutine ends, then perl will keep the data so that the other
reference(s) can use it. It will no longer be accessible from the
subroutines hash (after all the hash has gone out of scope.) but will
remain in memory somewhere. (perhaps causing a memory leak if you
don't realize that you are asking perl to save data you have no need
for.)
-- 
Andrew Langmead


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

Date: Wed, 23 Dec 1998 15:33:13 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: sizeof() function?
Message-Id: <F4FCJE.Coo@world.std.com>

bart.lateur@skynet.be (Bart Lateur) writes:

>Andrew M. Langmead wrote:

>>There is a
>>length() function, which is like C's strlen()

>Not really. Perl strings may contain null bytes.

That means that Perl's strings are different than C's strings, not
that the meaning of the function is different. Both functions return
the length of the string, for its language's definition of a string.

Also since you decided to start the nit-picking, the word "like"
implies "similar to", not "feature and deficit identical to".

Lastly, how does this information help Sean find what he thought was
the sizeof() function in Perl.

-- 
Andrew Langmead


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

Date: Wed, 23 Dec 1998 15:52:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Socket Initialize error
Message-Id: <F4FDFx.38u@world.std.com>

Arvind Krishnaswamy <arvindk@pa.dec.com> writes:

>If I get an error like -

>Failed to initialize socket: Address family not supported by protocol
>family


There is an entry in the FAQ that may help titled: "Why doesn't my
sockets program work under System V (Solaris)? What does the error
message "Protocol not supported" mean?"
 
>#!/usr/local/bin/perl5
>use Socket;
>$server = "av-dev.xxx.dec.com";
>$port = 7777;
>$AF_INET = 2;
>$SOCK_STREAM = 1;
>$server_addr =(gethostbyname($server))[4];


The Socket module that you are including contains constants named
SOCKET_STREAM and AF_INET (notice without the "$", they are really
subroutines that return a constant value) that are correct for the
operating system you are running under.

There are examples in some older documentation that show the
hard-coding of socket constants in the script. (These being written in
the "all the world is a Sun workstation days". But now, even Sun's
products don't fit the assumptions people made then.) but now, you
should use the information in Socket.pm instead.

>$server_struct = pack("S n a4 x8", AF_INET, $port, $server_addr);

and you might want to change this to:

   $server_struct = sockaddr_in($port, $server_addr);

To prevent any problems with your operating system's C struct padding
idiosyncrasies.

Probably the best place to crib socket handling code from is the
perlipc man page.

-- 
Andrew Langmead


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

Date: 23 Dec 1998 14:28:09 +0100
From: rutka@lucent.com (Micha3 Rutka)
Subject: Re: sort it ?
Message-Id: <wsm4sqn56om.fsf@hzsac328.nl.lucent.com>

John Porter <jdporter@min.net> writes:
> Micha3 Rutka wrote:
> > 
> > You can speed up even more if you use the original technique (without a
> > name yet) ...
> 
> Doesn't need a name.

Then why are you calling it 'stringify'? Am I missing something?

> Remember, kids: use the built-in sort comparison if the performance
> of your sorts is a concern.

Hym, really father ?-).

OK. Let see (the same benchmark numbers, which Larry used):

@datai = ();
foreach (1..100){
  push @datai, int(rand(1000));
}

sub _Normal_sort{
  my @sorted = sort {$a <=> $b} @datai;
}

sub _Fancy_sort{
  my @sorted = map {substr($_,4)}
               sort
	       map {pack("N",$_).$_} @datai;
}

use Benchmark;

timethese(1000,{
	     'Int sort' => \&_Normal_sort,
	     'Str sort' => \&_Fancy_sort,
               }
         );

Reports,
Benchmark: timing 1000 iterations of Int sort, Str sort...
  Int sort:  3 secs ( 3.76 usr  0.00 sys =  3.76 cpu)
  Str sort:  6 secs ( 5.94 usr  0.01 sys =  5.95 cpu)

So, your rule-of-thumb gave me almost 2x slow-down. Or maybe you
should add some sub-rule-of-thumbs to your rule-of-thumb?

Michal

-- 
Dr. Ir. Michal Rutka       Lucent Technologies - Huizen, The Netherlands
Senior System Engineer     mailto:rutka@lucent.com


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

Date: Wed, 23 Dec 1998 06:36:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sort it ?
Message-Id: <MPG.10ea9fd629a6b169989971@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <wsm4sqn56om.fsf@hzsac328.nl.lucent.com> on 23 Dec 1998 
14:28:09 +0100, Micha3 Rutka <rutka@lucent.com> says...
+ John Porter <jdporter@min.net> writes:
+ > Micha3 Rutka wrote:
+ > MR> You can speed up even more if you use the original technique
+ > MR> (without a name yet) ...
+ > Doesn't need a name.
+ Then why are you calling it 'stringify'? Am I missing something?

We are calling it 'default sort' for now.
 
+ > Remember, kids: use the built-in sort comparison if the performance
+ > of your sorts is a concern.
+ 
+ Hym, really father ?-).
+ 
+ OK. Let see (the same benchmark numbers, which Larry used):
+ 
+ @datai = ();
+ foreach (1..100){
+   push @datai, int(rand(1000));
+ }
+ 
+ sub _Normal_sort{
+   my @sorted = sort {$a <=> $b} @datai;
+ }
+ 
+ sub _Fancy_sort{
+   my @sorted = map {substr($_,4)}
+                sort
+ 	       map {pack("N",$_).$_} @datai;
+ }
+ 
+ use Benchmark;
+ 
+ timethese(1000,{
+ 	     'Int sort' => \&_Normal_sort,
+ 	     'Str sort' => \&_Fancy_sort,
+                }
+          );
+ 
+ Reports,
+ Benchmark: timing 1000 iterations of Int sort, Str sort...
+   Int sort:  3 secs ( 3.76 usr  0.00 sys =  3.76 cpu)
+   Str sort:  6 secs ( 5.94 usr  0.01 sys =  5.95 cpu)
+ 
+ So, your rule-of-thumb gave me almost 2x slow-down. Or maybe you
+ should add some sub-rule-of-thumbs to your rule-of-thumb?

What you labeled _Normal_sort should be labeled _Trivial_sort.  And 
trivial sorts should be handled trivially!  (This includes, for example, 
'sort a hash by values' as well as your even more trivial case.)

What we have been talking about is a *fielded* sort -- one that requires 
the sort keys to be computed from the data.  The proper comparisons are 
to the various published ways of doing this:  in the comparison 
function, every time (the naive sort);  in the comparison function, Or-
cached;  cached via a preprocessing map (separate or Schwartz 
Transform).

It is possible that you are the only follower of this discussion who 
chose to ignore this obvious distinction.

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


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

Date: Wed, 23 Dec 1998 13:45:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Turning Variables into CAPS?
Message-Id: <3680F5C5.11F57F6F@home.com>

[posted & mailed]

Kai wrote:
> 
> >
> > Why do you want to transliterate '[' to '[' and ']' to ']'?  :-)
> >
> 
> Those caracters are not transliterated, they serve as delimiters for 
> the ranges a-z and A-Z.

No they don't, hence the smiley in Larry's post.  They would be
delimiters of a character class in a regex, but tr doesn't use regexes.

perldoc perlop

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Wed, 23 Dec 1998 10:11:31 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: What's wrong with this code?
Message-Id: <36810823.7F341F09@cthulhu.demon.nl>

WL wrote:
> 
> Then, I added this bit of code afer the print MAIL Subject line:
> 
> print MAIL "$in{'City'}";
> 
> This takes the text City variable from the web page - but it didn't, or
> rather it returned a server error :((  I use the post statement, - could
> this have been the problem?

Figure out whether $in{'City'} actually exists. Check the result of
the close. Write to a file instead of sendmail, and check whether
the file looks correct. Run it through sendmail by hand to see if that
works. Try to find a copy of the 'Debugging for dummies book' :)

> I'd be very grateful for any help, to will@localads.net

Sorry, you posted it here, you'll have to read it here.

Erik
-- 
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely.  And everyone who owns a car intends that it be used as a
portable dumpster.  Any unwanted garbage in their vehicle they can
simply throw away, after all.



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

Date: Tue, 22 Dec 1998 08:44:21 -0600
From: "Gary W. Propp" <gary.w.propp@cdc.com>
Subject: Where can you get undump
Message-Id: <75oaj2$h6c$1@cdshub.cdc.com>

I would like to improve the performance of some perl programs. I understand
that the
dump function produces a image core dump. The documentation I have indicates
you
need a program undump that is not part of the Perl distribution. Where can
you get undump?




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

Date: Wed, 23 Dec 1998 14:37:08 +0100
From: jwl@worldmusic.de (Joergen W. Lang)
Subject: while (<>) and $!\n
Message-Id: <1dkhuft.1ctzydf1piayhiN@host024-210.seicom.net>

As far as I know the standard behaviour of while (<>) is 

    open F, "test" or die "Can't open test: $!\n";
    # Newline at the end, gives
    # Can't open test: No such file or directory

Is there any way of changing this to

    open F, test or die "Can't open test: $!";
    # No newline, gives
    # Can't open test: No such file or directory.
    File 'open_test.pl'; Line 2

so I can catch the script name and line number ? Is there any standard
way I am missing ? I couldn'd find anything in neither Camel, Llama,
Pod....

Any pointers welcome.

Joergen

-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: Wed, 23 Dec 1998 10:25:19 -0500
From: jamesht <jamesht@idt.net>
To: "Joergen W. Lang" <jwl@worldmusic.de>
Subject: Re: while (<>) and $!\n
Message-Id: <36810B5F.76C6B4C9@idt.net>

Hello,

You can use __FILE__ and __LINE__ to get the current filename and
linenumber.

James



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

Date: Wed, 23 Dec 1998 10:24:32 -0500
From: jamesht <jamesht@idt.net>
To: "Joergen W. Lang" <jwl@worldmusic.de>
Subject: Re: while (<>) and $!\n
Message-Id: <36810B30.AA75A093@idt.net>

Hello,

You can use __FILE__ and __LINE__ to get the current filename and
linenumber.

James



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

Date: Wed, 23 Dec 1998 09:19:15 -0500
From: Jeff Crosby <jlcrosby@fwi.com>
Subject: Re: Win Port - AWK to Perl conversion
Message-Id: <3680FBE3.EA31F33F@fwi.com>

"Allan M. Due" wrote:
 
> Good plan, although if you are a fellow POB, Learning Perl on Win32 System has
> a few helpful hints.

I forgot to ask, what's POB?  Programmer On Basic?  Plain Ol' Boy? 
Pretty Old B*****d?
<g>
 
> This finds my copy of ActiveStates a2p.exe in the bin subdirectory of my perl

I went back out onto the web and found a file, API508E.EXE, which I am
downloading as we 'speak'.  Evidently the other file I had was something
totally different, although it had BIN, DOCS, and other directories
after installation, as well as a PERL.EXE.  Don't ask me, I'm just the
piano player.

-- 
-Jeff

jlcrosby@fwi.com


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

Date: Wed, 23 Dec 1998 14:30:36 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Win Port - AWK to Perl conversion
Message-Id: <3680fe3f.2065509@news.skynet.be>

Jeff Crosby wrote:

> forgot to ask, what's POB?  Programmer On Basic?  Plain Ol' Boy? 
>Pretty Old B*****d?

It's an invention of Tom Christiansen, first rate MS basher, I believe.

It's "Prisoner Of Bill". Yeah, THAT Bill.

	Bart.


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

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


Administrivia:

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

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

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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