[9801] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3394 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 7 20:07:11 1998

Date: Fri, 7 Aug 98 17:00:18 -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           Fri, 7 Aug 1998     Volume: 8 Number: 3394

Today's topics:
    Re: [Q] Problems building perl 5.004_4 on SGI (Joe McMahon)
        a couple of interesting things about win32perl vs binar (KHeise)
    Re: a couple of interesting things about win32perl vs b (Craig Berry)
    Re: ARGV truncations (Ian Collier)
    Re: ARGV truncations <ljz@asfast.com>
    Re: Autoincrement with hashes <jdf@pobox.com>
        Build on NT error: 5.004_74 <antoy@cs.pdx.edu>
    Re: c.l.p.moderated: not much traffic? <birgitt@hbg.citnet.de>
    Re: comp.lang.perl.announce redux <dsautereau@magic.fr>
    Re: comp.lang.perl.announce redux <birgitt@hbg.citnet.de>
    Re: confirm before submit (Craig Berry)
        create html files in htdocs c.clark@student.unsw.edu.au
        Cronjob and Perl "qq" command edwardv@jps.net
    Re: Cronjob and Perl "qq" command (Gary L. Burnore)
        Help interpreting error message <awrobinson@amoco.com>
        Help Needed please mikey7918@my-dejanews.com
    Re: Perl for kids: Partial work on-web <birgitt@hbg.citnet.de>
        Returning hashes of hashes posenj@lancet.co.za
        Socket & Storable don't mix? <fecund@fatnet.net>
        Status of MailTools-1.11 <Robert.Lopez@abq.sc.philips.com>
    Re: variable indirection [off topic - parens] <marks@webleicester.co.uk>
    Re: variable indirection [off topic - parens] (Craig Berry)
    Re: variable indirection [off topic - parens] (Nem W Schlecht)
        WANTED: Free Homepage Script (Scott)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 07 Aug 1998 16:55:22 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Re: [Q] Problems building perl 5.004_4 on SGI
Message-Id: <joe.mcmahon-0708981655220001@prtims.stx.com>

In article <m3ww8llrre.fsf@windlord.Stanford.EDU>, Russ Allbery
<rra@stanford.edu> wrote:

>k y n n <kj0@mailcity.com> writes:
>
>> Help!  Has anyone managed to build perl 5.004_4 on IRIX 6.3/mips 7.00?
>> I'm *almost* there, but the resulting executable bombs one test, bop.t
>> (bitwise operators).  In fact, it fails only 6 evaluations out of 18 in
>> that test.  For example, it thinks (~0 > 0) is false.
>
>Does it work better if you compile without optimization?  I think I've
>seen this one before....
For best results, use -32 (not -n32!) and -O2 (not -O3! the compiler will
coredump). Alter the config not to use /lib32, /usr/lib32, etc. Just generally
avoid -n32 to improve your life a lot.

 --- Joe M.


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

Date: 7 Aug 1998 21:50:33 GMT
From: kheise@aol.com (KHeise)
Subject: a couple of interesting things about win32perl vs binary data
Message-Id: <1998080721503400.RAA14046@ladder03.news.aol.com>

first off i want to thank anyone who has answered my questions in the past.
there was a problem i was having dealing with binary data, and i got a couple
of good responses. based on those and my own observations (meager as they may
be at this time) i would like to point out a few interesting things about perl
and binary data for beginners.

1) if you are outputting data in binary mode - binmode(FILEHANDLE) - the "\n"
character will generate only a line-feed (\x0A) instead of a
carrige-return/line-feed (CR/LF) (\x0D\x0A) as it normally does.

ex.
open (OUTFILE,'>test.out');
binmode (OUTFILE);
    print OUTFILE "\n\n\n"

would output "\x0A\x0A\x0A"

open (OUTFILE,'>test.out');
    print OUTFILE "\n\n\n"

would output "\x0D\x0A\x0D\x0D\x0A\x0A"

2) similarly if you read in a chunk of binary data with a CR/LF on the end and
try to 'chomp' it, only the line-feed is eliminated.

3) i know this may be common knowledge, but it's why i spent hours scratching
my head --> input and output files must use the 'binmode' function.

hey, it might not be that much, but i want to contribute any way i can

-jay


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

Date: 7 Aug 1998 22:22:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: a couple of interesting things about win32perl vs binary data
Message-Id: <6qfuo1$s2m$3@marina.cinenet.net>

KHeise (kheise@aol.com) wrote:
: first off i want to thank anyone who has answered my questions in the past.
: there was a problem i was having dealing with binary data, and i got a couple
: of good responses. based on those and my own observations (meager as they may
: be at this time) i would like to point out a few interesting things about perl
: and binary data for beginners.
[snip]

Note that your (useful) comments apply only to the DOS/Windows family of
operating systems.  Under Unix, binmode is a no-op, while on the Mac I
believe \n is \0xD.

: hey, it might not be that much, but i want to contribute any way i can

Well, it's probably going to be useful in reducing confusion and
frustration in a lot of other people, so thanks very much for your
contribution. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 7 Aug 1998 21:32:54 GMT
From: imc@comlab.ox.ac.uk (Ian Collier)
Subject: Re: ARGV truncations
Message-Id: <15388-libel.imc@comlab.ox.ac.uk>

In article <35CB648B.4E69EDBD@us.ibm.com>, Kirk Moren <kirkmo@us.ibm.com> wrote:
>To provide an actual example would be quite lengthy since most argument
>lengths
>are close to 1000 bytes, but a good illustration would be the following...

But perhaps you could post the exact line of Rexx which does it.  It
might also depend on the interpreter and system.

>`perl perlsock.pl adv3.tpa.co.com 5000 0999data string preceded by 4 byte
>length of 0999 contains a string of data and special characters0a0dxthis is
>the end`

>@ARGV in perlsock only receives up to ... and special characters ... with all
>data past and including the 0a0dx hex string represenation being truncated.

I don't understand why you have written this command in backticks.  They
aren't valid characters in a Rexx program.  Anyway, here is a practical
example.

/* test program */
address unix
a='6162630d0a646566'x
'perl -le "print @ARGV"' a

This program might well print out "abc" and then say "sh: def: command not
found".  The reason is that the perl command is passed to a shell for
execution, and the shell sees the '0a'x as the end of the command.  You
need to make sure the argument is quoted properly so that this and other
unwanted effects don't happen.  If you are using unix then "address command"
would probably be advisable too.

Does this describe anything like what you are trying to do?
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page below
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


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

Date: 07 Aug 1998 19:25:22 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: ARGV truncations
Message-Id: <ltww8knzml.fsf@asfast.com>

Kirk Moren <kirkmo@us.ibm.com> writes:

> Nem W Schlecht wrote:
> 
> > [courtesy copy e-mailed to author(s)]
> >
> > In comp.lang.perl.misc, Kirk Moren  <kirkmo@us.ibm.com> wrote:
> > >I have a situation where an rexx program is calling a perl 5 program to
> > >perform some socket i/o.   The data is being passed to the perl program
> > >via arguments such as...
> > >
> > > [ ... ]
> 
> [ ... ]
>
> To provide an actual example would be quite lengthy since most argument
> lengths
> are close to 1000 bytes, but a good illustration would be the following...
> 
> `perl perlsock.pl adv3.tpa.co.com 5000 0999data string preceded by 4 byte
> length of 0999 contains a string of data and special characters0a0dxthis is
> the end`
> 
> @ARGV in perlsock only receives up to ... and special characters ... with all
> data past and including the 0a0dx hex string represenation being truncated.

You're invoking the Perl program from Rexx, and so it looks as if it's
Rexx which is somehow interpreting the special characters in its
efforts to construct the command line which you are passing to Perl.
It appears as if Rexx is interpreting `0a0dx' as a
carriage-return-linefeed pair and truncating (or splitting?) the
command line at that point.

I bet that you would get the same truncated command line if you invoked
the following command in Rexx:

 `echo perlsock.pl adv3.tpa.co.com 5000 0999data string preceded by 4 byte
 length of 0999 contains a string of data and special characters0a0dxthis is
 the end`

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 07 Aug 1998 17:27:58 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Autoincrement with hashes
Message-Id: <1zqsctqp.fsf@mailhost.panix.com>

gebis@fee.ecn.purdue.edu (Michael J Gebis) writes:

> Jonathan Feinberg <jdf@pobox.com> writes:
> }  foreach (@$_) { $ALL_FIELDS{$_}++ }
> 
> }It's a common idiom for autovivifying hash elements.  If $h{foo}
> }doesn't exist, then the phrase $h{foo}++ will bring it into existance.
> }The fact that its value is now 1 is immaterial.  If we run into foo
> }again, the value will increase, but it's only the existance of the key
> }foo that interests us.
> 
> I think Jonathan means, "The value is the number of times the element
> appeared in the original array, and thus is sometimes indispensible."
> :)

You're right; that was a typo.  Thanks.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Fri, 07 Aug 1998 16:49:38 -0700
From: Sergio Antoy <antoy@cs.pdx.edu>
Subject: Build on NT error: 5.004_74
Message-Id: <35CB9292.4CB22E64@cs.pdx.edu>

Hi all,

I built 5.004_74 on NT. Almost everything went well, and perl
works, except for the following

	..\perl.exe -I..\lib ..\installhtml --podroot=.. --htmldir=./html 
--podpath=pod:lib:ext:utils
--htmlroot="file://e|\Stuff\perl\5.00474\lib\pod\html" 
--libpod=perlfunc:perlguts:perlvar:perlrun:perlop --recurse
 ..\installhtml: ../pod/perldebug.pod: cannot resolve LTerm::ReadLine in
paragraph 132: no .pod or .pm found
 ..\installhtml: ../pod/perldelta.pod: cannot resolve L<INSTALL> in
paragraph 9: no such page 'INSTALL'
 ..\installhtml: ../pod/perldelta.pod: cannot resolve L<INSTALL> in
paragraph 11: no such page 'INSTALL'
 ..\installhtml: ../pod/perldelta.pod: unexpected =item directive in
paragraph 18.  ignoring.
 ..\installhtml: ../pod/perldelta.pod: cannot resolve L<README.threads>
in paragraph 33: no such page 'README.threads'
[Many more similar lines omitted]

This does not seem to be a problem except when I use diagnostics.
If there are messages, then I get

couldn't find diagnostic data in
e:\Stuff\perl\5.00474\lib/pod/perldiag.pod ../../Library
E:\Stuff\perl\lib/MSWin32-x86 E:\Stuff\perl\lib
E:\Stuff\perl\site\5.00474\lib/MSWin32-x86
E:\Stuff\perl\site\5.00474\lib E:\Stuff\perl\site\lib . chooser.pl at
E:\Stuff\perl\lib/diagnostics.pm line 229, <POD_DIAG> chunk 533.
BEGIN failed--compilation aborted at ../../Library/DBident.pm line 8,
<POD_DIAG> chunk 533.
BEGIN failed--compilation aborted at chooser.pl line 31, <POD_DIAG>
chunk 533.
The process tried to write to a nonexistent pipe.


Does someone know how to fix this?

Thanks,
Sergio


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

Date: Fri, 07 Aug 1998 17:32:16 +0000
From: Birgitt Funk <birgitt@hbg.citnet.de>
Subject: Re: c.l.p.moderated: not much traffic?
Message-Id: <35CB3A20.4F1BA7D2@hbg.citnet.de>

Gabor wrote:
> 

> I think it's great to be able to read carefully all
> the posts, though I have noticed a flame war already brewing between the
> old guard in the group. :(

 ...can't live with them, can't live without them ... :-)

Birgitt Funk


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

Date: Fri, 07 Aug 1998 23:22:48 +0200
From: Damien Sautereau <dsautereau@magic.fr>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <35CB7028.3A3066E@magic.fr>



Birgitt Funk a icrit:

> Reason:
>
> I would not want to scan several regional perl NGs for
> *announcements* about events, books, articles, contests,
> conferences etc, but I would like to be able to be
> informed about them in *one* NG, and that is c.l.p.a.

Exactly.

> In that sense c.l.p.a is an exception - at least for me -.
>

It is for me too...

--
Damien Sautereau



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

Date: Fri, 07 Aug 1998 17:05:15 +0000
From: Birgitt Funk <birgitt@hbg.citnet.de>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <35CB33CB.A70AEEAB@hbg.citnet.de>

Jim Brewer wrote:
> 
> birgitt@minivend.com writes:
> 
> > No, more a lack of quality Perl books written in languages other
> > than English in the first place.
> >
> > But there are some and if they are good enough, they are either
> > immediately  written in English by authors whose native language
> > is not English, or they are considered good enough to be picked up
> > by publishers in the English spoken countries and translated.
> 
> Not being a smart alec, and I am actually very interested, could you
> provide a few titles?
> 

Effektives Programmieren mit Perl 5
by Michael Schilli
Addison-Wesley-Longman

GoTo Perl 5
by Michael Schilli
Addison-Wesley-Longman

In checking this out I discovered I made a mistake. I was
thinking GoTo Perl 5 was actually written in English and 
thought it was a translation of the German version of 
"Effektives Programmieren mit Perl 5", mislead by the 
English sounding title (and the fact that Schilli works
in the US).  

It is actually also written in German and just the enhanced 
newer edition of the first. Schilli is native German. So my 
statement that Perl books  have been translated into English 
from German was wrong. I apologize.

Perl:Einfuehrung, Anwendung, Referenz
by Farid Hajii
Addison-Wesely-Longman
Haven't seen the book yet, Hajii is not a German last name per se,
but the book is written in German and is not a translation from
another language.

Reviews for both are in the German Linux Magazin.

Programmieren in Perl
by Rainer Krienke, Dietmar Hennig, Martin Stroeebe
Publisher: Hanser, C

All the rest are translations from all the well known
English books. 

Birgitt Funk


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

Date: 7 Aug 1998 21:37:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: confirm before submit
Message-Id: <6qfs3h$s2m$2@marina.cinenet.net>

karen_green@vsl.com wrote:
: I have my a form and a CGI Script that shows a confirmation page and emails
: me the results.  I need to change this so that I display the confirmation
: page, give the user the option to make go back to make changes or submit the
: order via the confirmation page. Can anyone tell me how I would modify my
: code to do this.

The gist of the trick is to generate the confirmation page with everything
sent from the first page's form tucked into hidden input fields.  That
way, if they submit the confirmation page's form, all the data gets
carried forward.  Implementation is left as an exercise, but it's a
trivially simple loop if you use CGI.pm.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 07 Aug 1998 23:03:05 GMT
From: c.clark@student.unsw.edu.au
Subject: create html files in htdocs
Message-Id: <35cb86a3.615056@news.syd.enternet.com.au>


G'day,

I'm using an apache server.  I want to create HTML files in the htdocs
directory from a CGI program in Perl.  I have tried setting the path,
but it doesn't seem to work. 

I have no problems creating/deleting (or whatever) to files in the
cgi-bin directory, it's just when I try and go to the parent directory
and then into htdocs.

At the moment everything is default on the server.  Would it be a
permission thing?  Can anyone give me a quick example of the code?


Ta muchly,


Chris Clarke.


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

Date: Fri, 07 Aug 1998 22:04:17 GMT
From: edwardv@jps.net
Subject: Cronjob and Perl "qq" command
Message-Id: <6qftl1$t1d$1@nnrp1.dejanews.com>

Can any one tell me why my scripts work when i run them manually but when i
run them in a cron i get errors?  I think it has to do with perl's "qq"
command because if i take out everything associated with the 'qq' command, my
error goes away and the scripts work.  but obviously i need the 'qq'.  Thanks
in Advance.

"broken pipe" error on this script

#!/usr/local/bin/perl
chdir ("/u/scripts/edv");
$hh = 12;
$ENV{'INFORMIXSERVER'} = "n36_shm";
open (DBACCESS, "| dbaccess");
    print DBACCESS qq{
       database pmsys\@n36;
       UNLOAD TO 'abc.txt'
       SELECT MAX(ostime)
       FROM ama0_980806
       WHERE EXTEND (ostime, HOUR to HOUR) = "$hh";
    };
close (DBACCESS);
print "at end\n";



"sh: dbaccess: not found" error on this script

#!/usr/local/bin/perl
chdir ("/u/scripts/edv");
$hh = 2;
$ENV{INFORMIXSERVER} = "n36_shm";
   system qq{
   dbaccess << 'eof'
   database pmsys\@n36;
   UNLOAD TO 'abc.txt'
   SELECT cfc
   FROM ama0_980714
   GROUP BY direct, cfc
   HAVING direct = "$hh";
eof
   };

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


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

Date: Fri, 07 Aug 1998 22:21:17 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: Cronjob and Perl "qq" command
Message-Id: <35d37d80.86905027@nntpd.databasix.com>

On Fri, 07 Aug 1998 22:04:17 GMT, in article
<6qftl1$t1d$1@nnrp1.dejanews.com>, edwardv@jps.net wrote:

>Can any one tell me why my scripts work when i run them manually but when i
>run them in a cron i get errors? 

[snip code]

Because the environment variables INFORMIXSERVER and PATH aren't set correctly
without being EXPLICITYLY set from within the cron job itself.  Worst case,
call a shell script from cron that sets and exports the variables THEN calls
the perl code.
  
-- 
      I DO NOT WISH TO RECEIVE EMAIL IN REGARD TO USENET POSTS
---------------------------------------------------------------------------
                  How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore                       |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH!                                  |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3 3 4 1 4 2  ]3^3 6 9 0 6 9 ][3
Special Sig for perl groups.          |     Official Proof of Purchase
===========================================================================


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

Date: Fri, 07 Aug 1998 17:07:53 -0500
From: "Andrew W. Robinson" <awrobinson@amoco.com>
Subject: Help interpreting error message
Message-Id: <35CB7AB9.4E96320E@amoco.com>

I'm getting the following error message in a script I'm working
on:

  Use of uninitialized value at (eval 21) line 18.

I'm pretty sure the error is not on line 18 of the script, so I
assume (eval 21) implies some offset. What would that offset be?

TIA,

Andrew Robinson
-- 
Offshore Business Unit           email: awrobinson@amoco.com
Amoco Corporation                      phone: (504) 586-6888
New Orleans, LA                          fax: (504) 586-2637
-----
The events depicted herein are fictional. Any similarity to 
persons living or dead is entirely...oops, wrong disclaimer


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

Date: Fri, 07 Aug 1998 22:27:04 GMT
From: mikey7918@my-dejanews.com
Subject: Help Needed please
Message-Id: <6qfuvo$uek$1@nnrp1.dejanews.com>

Hello, I am trying to get an authentication script working, but it is not and
I don't know why.  I am getting very frustrated, so any help is appreciated.
Here is the script, I'll tell you what I am trying to do:

!/usr/local/bin/perl

push(@INC,"/magma/users/u20/hack/public_html/cgi-bin/teams");
require 'cgi-lib.pl';

&ReadParse;
print &PrintHeader;

open(PASS, "/default.txt") || die "Sorry, I couldn't open that file\n"; while
(<PASS>) {	  chomp($_);	  @f = split(/:/, $_);	  if ($f[0] eq
$in{'name'})		   {		   print "$ID Your $in{'name'} is the
same."; 	     print "That username is taken. Please chose another.";  
       } else { print <<'header'; Added user to database header print "$_";
print
"-------------------------------------------------------------------------
-------\n"; print &PrintVariables(%in); print "-------
-----------------------------------------------------------------
--------\n"; print "For the Love of God, please record your user name and
password, because from hereon in, your password is encrypted and not even I
know what it is. I can only change the damn thing.\n"; print "It might be a
good idea to print out this sheet (hint hint).\n"; print qq! Click here to go
back to the login page !; } close PASS;

open (PASS, ">>/default.txt") || die "Couldn't open it 2nd";
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($in{'passwd'}, $salt);
print PASS "$in{'name'}:$encrypted:1:1::1:\n";
close PASS;
$message = "User: $in{'name'} created.";
last CASE;
}

Whata I want to do is have the program lookup in "default.txt" the names of
everyone.  If the name of the person applying is found, then generate the
error message.	If not, write their data to a file.  I don't understand, I
think it looks right but I am missing something because it is only reading
the first line of the file, from what I can tell.  I want it to go through
every line until it finds that username.  If it finds it, error message. If
not, then it will write that info to the file. If you can help, I'd REALLY
(sorry for yelling :-) ) appreciate it. Thanks in advance. Mike Potter
www.inthehack.com &#137;

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


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

Date: Fri, 07 Aug 1998 17:48:56 +0000
From: Birgitt Funk <birgitt@hbg.citnet.de>
Subject: Re: Perl for kids: Partial work on-web
Message-Id: <35CB3E08.FC4200CE@hbg.citnet.de>

jonathan seth hayward wrote:
> 
> Earlier, I posted an article mentioning that I was working on a Perl book for
> children.  My little brothers seem very uninterested in Perl, and they were
> my main reason for writing.  For now, I have decided to drop the project.

I remember I was tempted at the time you posted that to 
give you a motherly advice not to get your hopes up. It's 
pretty hard to "instill interest" no matter how hard you try. 
It's a gift from the up on high if it happens, and at times I 
think may be also if it doesn't.:-) 

I bet you one of them will get interested later on and for sure
you never know ahead of time which one it will be. :-)

Birgitt Funk


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

Date: Fri, 07 Aug 1998 09:12:52 GMT
From: posenj@lancet.co.za
Subject: Returning hashes of hashes
Message-Id: <35cac459.8275815@news.saix.net>

As part of a database system, my script sends an array of hashes to a
function. The function moves these hashes from the array into a hash
(with the value of 'ID' key of the small hashes becoming the keys of
the big hash %hashhash).

However, the function returns an empty hash.

If I test the hash inside the function all seems to be in place. But
no so with the returned hash.

I have even tried to return a reference to the big hash and the
reference itself is returned okay (I checked that the returned address
is equal to the big hash address while inside the function). But after
applying a hash to the reference I again get an empty hash.

Any explanation and solution will be greatly appreciated.

Kevin Posen

The code follows:

{
  my @prefsarr = gethashes ('userpref.dat');
  my $prefsref = arr2hash (\@prefsarr, 'ID');	

  # $prefsref is equal to \%hashhash within the function &arr2hash

  my %prefs    = @$prefsref;	# but this is empty!!!
  print $prefsref;
  print ${$prefs}{0}{type};		# use of undefined variable!!!
}

sub gethashes
{
  open (DATFILE, $_[0]) or exitsub ($!);
  chomp(my @hasharr = <DATFILE>);
  close DATFILE;

  my @speckeys = split (/$split_on/, shift @hasharr);
  my @specs;

  my $i;
  my $key_i;
  for $i (0..$#hasharr)
  {
    @specs = split (/$split_on/, $hasharr[$i]);
    for $key_i (0..$#speckeys)
    { $hasharr[$i]{$speckeys[$key_i]} = $specs[$key_i]; }
  }

  return @hasharr;
}

sub arr2hash
{
  my $refarr  = $_[0];
  my @hasharr = @$refarr;
  my $hashby  = $_[1];
  my @keys    = keys %{$hasharr[0]};
  my $key;
  my %hashhash;

  foreach $hash (@hasharr)
  {
    foreach $key (@keys)
    {
      ${$hashhash}{${$hash}{$hashby}}{$key} = ${$hash}{$key} unless
($key eq $hashby);
    }
  }

  print ${$hashhash}{0}{type};		# over here it's defined
  print \%hashhash;
  return \%hashhash;
}


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

Date: Fri, 07 Aug 1998 15:44:54 -0700
From: Yary Hluchan <fecund@fatnet.net>
Subject: Socket & Storable don't mix?
Message-Id: <35CB8366.7300@fatnet.net>

Using GS binary distribution (thanks!), WinNT, version 5.004_02:

#!perl -w
use strict;
use Socket;

print join('.',unpack('CCCC',inet_aton('localhost'))),"\n";

__END__

works nicely, prints 127.0.0.1 on my laptop.
But add some lines, making this:

#!perl -w
use strict;
use Socket;
use Storable qw(nstore retrieve);

my $file = "foo.pls";
nstore {}, $file;
my %bar = %{retrieve $file};

print join('.',unpack('CCCC',inet_aton('localhost'))),"\n";
__END__
and I get:
Use of uninitialized value at tst.pl line 10.

inet_aton stops working!
Is this reproducable on your sustem?  Anyone know a workaround? Seems to
be the retrieve call that's clobberint inet_aton...

thanks
-yary


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

Date: 07 Aug 1998 15:19:25 -0600
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: Status of MailTools-1.11
Message-Id: <jc6af5gebhe.fsf@abqn07.ato.sca.philips.com>


I have been trying to download MailTools-1.11.tar.gz from
cpan and regardless of the site I can read the MailTools-1.11.readme
file but can not successfully down load any version of MailTools gz
file. I get "Unknown status reply from server: 1!"
What am I doing wrong?

-- 
Robert.Lopez@abq.sc.philips.com



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

Date: Fri, 07 Aug 1998 22:41:05 +0100
From: Mark <marks@webleicester.co.uk>
Subject: Re: variable indirection [off topic - parens]
Message-Id: <35CB7471.307FC578@webleicester.co.uk>

I have to agree too !  Parenthesis makes code:

    1) easier to read
    2) less likely to be bugged
    3) more likely to be correct !

Yes I know 2 and 3 are the same, but its such a big point.. I thought I'd
mention it twice ;)

I to have noticed people missing it out.. I don't know why !  It looks messy !

Mark.
--

Nem W Schlecht wrote:

> [courtesy copy e-mailed to author(s)]
>
> In comp.lang.perl.misc, Tom Christiansen  <tchrist@mox.perl.com> wrote:
> >In comp.lang.perl.misc, I wrote:
> >:    my (%names;
> >
> >     my %names;
>
> On a side note... I've noticed that a lot of code snippets posted to clpm
> are missing a lot of parens, IMO.  However, in looking at the perlobj man
> page (and others) I notice a lot of:
>
> my $self = {};
>
>  and
>
> bless $self, $class;
>
> Now, I've been off in my own little la-la land of perl programming for a
> couple of years now and I'm trying get back into posting more on clpm, but
> this is a bit shocking to me.  Is it generally taken that calls without
> parens are easier to read or somehow otherwise preferred?  I disagree, but
> that's merely my opinion.  Case in point, somebody followed up to one of my
> posts the other day, saying that my code:
>
> push(@ary, $_) while (<FH>);
>
> Could "be simplified to":
>
> push @ary, $_ while <FH>;
>
> To which I *mentally* replied, "This guy is $(*#ed up".  But with all the
> other code I've seen, I'm beginning to doubt my stance on this subject.
>
> --
> Nem W Schlecht                  nem@plains.nodak.edu
> NDUS UNIX SysAdmin        http://www.nodak.edu/~nem/
> "Perl did the magic.  I just waved the wand."
>





--
================================
Mark Simonetti
se96ms@dmu.ac.uk
marks@webleicester.co.uk
http://www.cms.dmu.ac.uk/~se96ms
================================

"I used to be indecisive, but now I'm not so sure."




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

Date: 7 Aug 1998 21:35:17 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: variable indirection [off topic - parens]
Message-Id: <6qfrul$s2m$1@marina.cinenet.net>

Nem W Schlecht (nem@abattoir.cc.ndsu.nodak.edu) wrote:
: On a side note... I've noticed that a lot of code snippets posted to clpm
: are missing a lot of parens, IMO.  However, in looking at the perlobj man
: page (and others) I notice a lot of:
: 
: my $self = {};
: 
:  and
: 
: bless $self, $class;
: 
: Now, I've been off in my own little la-la land of perl programming for a
: couple of years now and I'm trying get back into posting more on clpm, but
: this is a bit shocking to me.  Is it generally taken that calls without
: parens are easier to read or somehow otherwise preferred?  I disagree, but
: that's merely my opinion.

It's all a matter of style, of course, but I think many people tend to
favor paren-reduced code simply because it produces less cluttered
expressions.  Once you get used to reading it, it also feels quite
natural.  Needless to say, I and others add parens when precedence or
grouping might be ambiguous to a human reader, as was discussed on the
thread concerning parens in math expressions a couple of weeks ago.

Note, by the way, that

  my $foo = @bar;

and

  my ($foo) = @bar;

mean very different things.  Treating 'my' as a function leads to all
kinds of conceptual breakdowns. 

: Case in point, somebody followed up to one of my
: posts the other day, saying that my code:
:
: push(@ary, $_) while (<FH>);
: 
: Could "be simplified to":
: 
: push @ary, $_ while <FH>;
: 
: To which I *mentally* replied, "This guy is $(*#ed up".

Speaking as said guy, I can assure you that you were entirely correct in
your initial assessment. :-)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 7 Aug 1998 17:38:45 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: variable indirection [off topic - parens]
Message-Id: <6qfvll$rpl@abattoir.cc.ndsu.nodak.edu>

In comp.lang.perl.misc, Craig Berry <cberry@cinenet.net> wrote:
>Nem W Schlecht (nem@abattoir.cc.ndsu.nodak.edu) wrote:
>: On a side note... I've noticed that a lot of code snippets posted to clpm
>: are missing a lot of parens, IMO.  However, in looking at the perlobj man
>: page (and others) I notice a lot of:
>: 
>: my $self = {};
>:  and
>: bless $self, $class;
>
>It's all a matter of style, of course, but I think many people tend to
>favor paren-reduced code simply because it produces less cluttered
>expressions.  Once you get used to reading it, it also feels quite
>natural.  Needless to say, I and others add parens when precedence or
>grouping might be ambiguous to a human reader, as was discussed on the
>thread concerning parens in math expressions a couple of weeks ago.
>
>Note, by the way, that
>
>  my $foo = @bar;
>and
>  my ($foo) = @bar;
>
>mean very different things.  Treating 'my' as a function leads to all
>kinds of conceptual breakdowns. 

Well, there I disagree again.  The above, non-paren statement, should be
written as:

  my($foo) = scalar @bar;

to avoid the confusion, IMO.  As we both know, many 'newbie' users get
their '@' and '$' mixed up when dealing with arrays.  Even in looking
through the documentation in perlsub, it is confusing what some of the
examples are doing, because of the lack of parens or the lack of a scalar()
call.  I know what is going on, but to a new reader, it might be very
confusing.

I'm sure I do many things considered stylistically 'taboo' in my own code,
but when I post an answer to a question, I put in a bunch of other stuff to
make sure that the questioner gets easy to understand code, albeit
sometimes more "cluttered", as you say.

>: To which I *mentally* replied, "This guy is $(*#ed up".
>
>Speaking as said guy, I can assure you that you were entirely correct in
>your initial assessment. :-)

I appreciate your candor! ;-)

-- 
Nem W Schlecht                  nem@plains.nodak.edu
NDUS UNIX SysAdmin        http://www.nodak.edu/~nem/
"Perl did the magic.  I just waved the wand."


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

Date: Fri, 07 Aug 1998 23:05:05 GMT
From: troutster@earthlink.net (Scott)
Subject: WANTED: Free Homepage Script
Message-Id: <35cb87ef.609589@news.earthlink.net>

Hi,
I would like to know if anyone knows where I can get a script that
would allow me to offer my visitors automated free homepages.
Anyone?


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

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

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