[10957] in Perl-Users-Digest
Perl-Users Digest, Issue: 4558 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 5 18:07:23 1999
Date: Tue, 5 Jan 99 15:00:25 -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 Tue, 5 Jan 1999 Volume: 8 Number: 4558
Today's topics:
Re: [OT] email address == passwd (Was: Re: OK I give up <ludlow@us.ibm.com>
Add a link Script <peter_oud@iname.com>
Re: basic query about command line processing in Perl <jdf@pobox.com>
Combining Animated Gifs in Perl? <support@counter.w-dt.com>
comp.lang.perl.misc,comp.programming <joshw@starmail.com>
Re: comp.lang.perl.misc,comp.programming (Abigail)
DB_File creation problem. (Mike D.)
Re: Does 'require' run the script automatically? (Bart Lateur)
Re: Excel to HTML converter? <meint.post@tref.nl>
Re: Excel to HTML converter? <Bob@b-tech.net>
Re: Excel to HTML converter? (Abigail)
Re: help with embedded Perl - accessing complex data st (Timothy C. Gion)
How do I create a unique (reproducible) identifier? <callahan@pmel.noaa.gov>
IO.pm and/or Dynaloader problems? (Nathan Gasser)
Re: looking for perl programmer (Craig Berry)
Re: looking for perl programmer <dgris@moiraine.dimensional.com>
Re: looking for perl programmer <dgris@moiraine.dimensional.com>
Re: looking for perl programmer <uri@ibnets.com>
Re: newline (Tad McClellan)
Re: Opening remote file (Clay Irving)
Order of building a multi-level hash rmore1@my-dejanews.com
Re: Order of building a multi-level hash <dgris@moiraine.dimensional.com>
Re: Order of building a multi-level hash <uri@ibnets.com>
Perl + Excel OLE <Bob@b-tech.net>
Re: PERL and permissions (Bart Lateur)
Re: Perl CD Bookshelf plans <tripp.lilley@perspex.com>
Re: Perl CD Bookshelf plans <jdf@pobox.com>
Re: Perl CD Bookshelf plans <dgris@moiraine.dimensional.com>
Re: Question: How to spawn another program and then die <mishra.aditya@emeryworld.com>
Re: Quick operator question <cw@dwc.ch>
Re: sort hash by values <d-edwards@nospam.uchicago.edu>
Re: sort hash by values (Tad McClellan)
subroutine declaration in a loop and lexical variables <B.A.McCauley@bham.ac.uk>
Re: subroutine returning an lvalue <roland.huss@consol.de>
Re: Web server in perl (Alastair)
Re: which database to take for perl + tk + win32? <meint.post@tref.nl>
Win32::AdminMisc::LogonAsUser... Any success? (Victor A. Cuya)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Jan 1999 16:02:47 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: [OT] email address == passwd (Was: Re: OK I give up (After a WEEK!))
Message-Id: <36928C07.C05834F7@us.ibm.com>
Abigail wrote:
> James Ludlow (ludlow@us.ibm.com) wrote on MCMLIII September MCMXCIII in
> <URL:news:36922C64.F1AF729B@us.ibm.com>:
> `` Marc Austin wrote:
> `` > if Joe loses his password, I want him to be able to request it again
> `` > using a simple online form...
> ``
> `` > Joe will submit his email address (requesting his lost password)
> `` > the script will look to see if it's in the temp.txt file. if Joe
> `` > Blows email address is in the text file then email joe his password...
> ``
> `` Of course, this means that the passwords are now actually the email
> `` addresses themselves. Basically, if someone knows an email address,
> `` they can get the password for free.
>
> Ah, yes. Except that the password will be mailed to the given email
> address.
Oh yeah. Duh. That would be the sensible thing to do wouldn't it.
And, it's even right there in the original post. I just had this
horrible vision of a website spitting out passwords to anyone who cared
to ask for them. My bad.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Tue, 05 Jan 1999 22:15:14 +0100
From: Peter Oud <peter_oud@iname.com>
Subject: Add a link Script
Message-Id: <369280E2.6868@iname.com>
Hi,
I searching for an add a link (and description) script.
Something like Geocities or Xoom use.
There are several scripts that place ALL the links on
ONE page (often with topics or letters A-Z). But I
want one that creates a NEW PAGE after a certain number
of entries. The script should add numbers at the foot
of the page: 1-2-3 etc. that link to more entries.
I hope someone can help me,
Thanks
------------------------------
Date: 05 Jan 1999 23:19:02 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Tom Morris" <tkkb@morrita.freeserve.co.uk>
Subject: Re: basic query about command line processing in Perl
Message-Id: <m3aezxnz1l.fsf@joshua.panix.com>
"Tom Morris" <tkkb@morrita.freeserve.co.uk> writes:
> can someone please help me out here. I'm a bit new to Perl and
> desparately need to know how to process command line args.
See the perlvar document, in the @ARGV section.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 05 Jan 1999 15:40:09 -0600
From: Mike <support@counter.w-dt.com>
Subject: Combining Animated Gifs in Perl?
Message-Id: <369286B8.AA16F15@counter.w-dt.com>
Does any one know of a program that would allow me to combine two gifs,
one animated and one unanimated? By combining I mean place the
unanimated one to the right of the animated one and combine it into one
image file. I have been using fly but it seems that it doesn;t support
animated gifs. Please reply if you know of any program or if you have
some source code that would allow this in perl. Thanks.
------------------------------
Date: Tue, 05 Jan 1999 22:11:49 +0100
From: Josh Want <joshw@starmail.com>
Subject: comp.lang.perl.misc,comp.programming
Message-Id: <36928015.3387@starmail.com>
Hello,
I am looking for a script that detects and automatically
removes broken links and the comments behind them on my site
(I have got a large number of bookmarks with comments).
Yahoo should have the same problem (on a far larger scale).
Thanks,
Josh
------------------------------
Date: 5 Jan 1999 22:05:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: comp.lang.perl.misc,comp.programming
Message-Id: <76u2am$ef8$2@client3.news.psi.net>
Josh Want (joshw@starmail.com) wrote on MCMLIII September MCMXCIII in
<URL:news:36928015.3387@starmail.com>:
$$
$$ I am looking for a script that detects and automatically
$$ removes broken links and the comments behind them on my site
$$ (I have got a large number of bookmarks with comments).
So, you want to remove a link even if a server is temporarely
unreachable?
$$ Yahoo should have the same problem (on a far larger scale).
I doubt they are looking for a script.
What exactly is your Perl question?
Abigail
------------------------------
Date: Tue, 05 Jan 1999 22:14:26 GMT
From: sprintfer@yahoo.com (Mike D.)
Subject: DB_File creation problem.
Message-Id: <36928cd0.11960468@nntp.cts.com>
For some reason I am loosing data when creating a large DB file.
To create the file, I use:
use Fcntl;
use DB_File;
$index_name = "tbs.idx";
$in_name = "sb_mmy.int";
my $index_obj = tie(my %index, "DB_File", $index_name, O_RDWR|O_CREAT,
0666) or die "Can't read: $file_name data";
open(FILE, "$in_name") or die "Can't read $in_name";
while(<FILE>) {
@data = unpack("A12A12A3A1A4A8A25A25A4A2A6A10A8", $_);
$mmy = $data[6] . ":" . $data[7] . ":" . $data[8];
$index{$mmy} .= $data[12];
}
$num = scalar(keys(%index));
$index_obj->sync;
untie(%index);
print $num, "\n";
The program prints 20886 and creates tbs.idx
But when I look at the DB file again and run scalar(keys(%index)) it
reports 13321. Looking at the data, it seems the first program did
not write 7565 keys! Why?
Mike D.
sprintfer@yahoo.com
------------------------------
Date: Tue, 05 Jan 1999 22:41:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Does 'require' run the script automatically?
Message-Id: <369491a1.1942642@news.skynet.be>
strattner@my-dejanews.com wrote:
>What I would like to do is to call the subroutines from another script. I
>thought it was as simple as adding the path to @INC and using require.
>However, when I did that, it appears that the entire script is run, as
>opposed to the subroutine only.
Indeed. Files that get "require"-d, are indeed executed: sub definitions
are added to the table of functions, and bare code is executed. Thus,
the bare code should only contain initialisation code, that needs to be
run once.
Example: a (static) hash can be filled on startup, e.g. a html entity
conversion hash:
%entity = ( '&' => 'amp', '<' => 'lt', '>' => 'gt',
# more may be added here ...
);
If you need to have the inverse as well, now is the time to create the
inverse hash, by code.
The "1;" at the end of the file lets YOU, the programmer, decide if any
of the initialisation code failed, and break off the rest of the main
program. A final true value at the end (if executed last) is the
indication that "all is well".
That's the theory. In practice, you should cut the subs and any
initialisation from the original program, and put them into a separate
script file. Add a "1;" at the end. "Require" this file, both from the
original (now reduced) script, and from your new script.
Congratulations: you now made your first step in actually reusing
code. Now, if for example you find a bug in this code, you only have to
fix it once.
HTH,
Bart.
------------------------------
Date: Tue, 5 Jan 1999 22:04:36 +0100
From: "Meint Post" <meint.post@tref.nl>
Subject: Re: Excel to HTML converter?
Message-Id: <76turn$nun$1@rubens.telebyte.nl>
or use the win32::ole module (I assume you're on a win32 platform) to get to
the Excel information and put this in a HTML template. I used this approach
for converting Word 97 documents to HTML and it works fine.
Meint
--
Hilta Goatfounder was all lace and shawls and colours
and earrings and so many bangles that a mere movement
of her arms sounded like a percussion section falling off a cliff.
------------------------------
Date: Wed, 6 Jan 1999 08:33:19 +1100
From: "Bob Reynolds" <Bob@b-tech.net>
Subject: Re: Excel to HTML converter?
Message-Id: <76u0k6$469$1@news0-alterdial.uu.net>
Hi Damon,
We have some perl scripts that manipulate Excel data and publish reports,
what i do is have a macro that uses excels save as html option, i call the
macro from the perl script and the macro does the save as.....
hope that helps...
Damon K. Haley wrote in message ...
>Hello,
>
>Is there an excel to html converter out there?
>I found MSWordview which does a great jobs
>of converting Word97 to html.
>http://www.gnu.org/~caolan/docs/MSWordView.html
>
>I also found this page (http://arturo.directmail.org/filters/)
>of MS converters but didn't find an excel2html
>converter that is available yet.
>
>Does anyone know of one or when one will be released?
>
>Thanks
>
>Damon Haley
------------------------------
Date: 5 Jan 1999 22:06:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Excel to HTML converter?
Message-Id: <76u2dd$ef8$3@client3.news.psi.net>
Damon K. Haley (dhaley@infobeat.com) wrote on MCMLIII September MCMXCIII
in <URL:news:slrn794puk.als.dhaley@dhcp132.corp.merc.com>:
""
"" Is there an excel to html converter out there?
Maybe. But what does that have to do with Perl?
Abigail
------------------------------
Date: 5 Jan 1999 21:29:53 GMT
From: tcg3j@cobra.cs.virginia.edu (Timothy C. Gion)
Subject: Re: help with embedded Perl - accessing complex data structure
Message-Id: <76u08h$pao$1@murdoch.acc.Virginia.EDU>
After further work on the problem, I've condensed it to not being able to
properly extract the complex data structure in C++. My perl program now
just creates a simple test case, but I get a bus error when I try to
extract elements of the data structure. The code follows below. Any help
would be greatly appreciated.
Tim
--------- units.pl -----------
#!/opt/bin/perl
sub get_unit_info
{
use strict 'refs';
require "dumpvar.pl" or die "Can't open dumpvar.pl!\n";
my $units = $_[0];
%{$units} = (
2202 =>
[75,
[ [2000, "tank", 5, 3],
[2100, "men", 100, 50] ],
[ ["ammo", 3000, 1500],
["pol", 2000, 500] ]
],
2205 =>
[75,
[ [2000, "tank", 5, 4],
[2100, "men", 100, 75] ],
[ ["ammo", 4000, 2500],
["pol", 4000, 1500] ]
]
);
dumpValue (\%{$units});
}
----- callunits.cpp --------
#include <iostream.h>
#include <EXTERN.h>
#include <perl.h>
int main(int argc, char** argv, char** env)
{
char *args[3] = { "callperl", "-d", "units.pl" };
PerlInterpreter* perl_int = perl_alloc();
perl_construct(perl_int);
perl_parse(perl_int, NULL, 3, args, NULL);
HV* table = newHV();
if(table == NULL) {
cerr << "Error: couldn't allocate new hash table\n" << endl;
return 1;
}
// hv_store(table, "water", 5, newSViv(50), 0 );
SV* tableref = newRV( (SV*) table);
dSP;
ENTER;
SAVETMPS;
PUSHMARK(sp);
XPUSHs(tableref);
PUTBACK;
perl_call_pv("get_unit_info", G_DISCARD);
SPAGAIN;
hv_iterinit(table);
HE* entry = hv_iternext(table);
for(; entry != NULL; entry = hv_iternext(table) ) {
I32 len;
char* key = hv_iterkey(entry, &len);
cout << "key = " << key << endl;
SV* val = hv_iterval(table, entry);
cout << "address: " << SvPV(val, SvCUR(val)) << endl;
cout << "num elements = " << av_len( (AV*) (SvRV(val)))+1 << endl;
// this should be a scalar int
SV** str = av_fetch( (AV*) SvRV(val), 0, 0);
cout << "str = " << SvPV(*str, SvCUR(*str) ) << endl;
// this should be a ref to an array of refs
SV** arr1 = av_fetch( (AV*) SvRV(val), 1, 0);
cout << "arr1 = " << SvPV(*arr1, SvCUR(*arr1) ) << endl;
// this should be a ref to an array of refs
SV** arr2 = av_fetch( (AV*) SvRV(val), 2, 0);
cout << "arr2 = " << SvPV(*arr2, SvCUR(*arr2) ) << endl;
// get first array referenced
SV** supply = av_fetch( (AV*) SvRV(*arr2), 0, 0);
// get first element of array
SV** supply_name = av_fetch( (AV*) SvRV(*supply), 0, 0);
cout << SvPV(*supply_name, SvCUR(*supply_name) ) << endl;
}
PUTBACK;
FREETMPS;
LEAVE;
perl_destruct(perl_int);
perl_free(perl_int);
return 0;
}
------------------------------
Date: Tue, 05 Jan 1999 14:13:45 -0800
From: Jonathan Callahan <callahan@pmel.noaa.gov>
Subject: How do I create a unique (reproducible) identifier?
Message-Id: <36928E98.3C6685DD@pmel.noaa.gov>
I'd like to take a series of name=value paris (from an HTML form
submission) and convert them into a unique ascii identifier to use for a
filename which my cgi process will create. The concatenation of all the
values is unique but unpleasantly long and I was hoping to find
something that would create a short, unique identifier string. But it
needs to be reproducible: I need to create the same unique identifier
if the same name=value pairs are passed in so that the previously
created file can be found rather than recreated.
Thanks in advance for any suggestions,
-- Jon
------------------------------
Date: 5 Jan 1999 17:32:36 +0500
From: gasser@spruce.libertynet.org (Nathan Gasser)
Subject: IO.pm and/or Dynaloader problems?
Message-Id: <36929304.0@news.dca.net>
Hi all,
I'm working with XML.pm and all was fine until today. It's installed
on two identical NFS'ed machines (BSDI) and on one, a "use XML.pm" bails.
I tracked it down to IO.pm and this is what I get:
=======
% perl -c IO.pm
Can't load '/usr/local/lib/perl5/5.00551/i386-bsdos/auto/IO/IO.o' for module IO: can't resolve undefined symbols: Inappropriate file type or format at /usr/local/lib/perl5/5.00551/i386-bsdos/DynaLoader.pm line 168.
at /usr/local/lib/perl5/5.00551/i386-bsdos/IO/Handle.pm line 248
BEGIN failed--compilation aborted at IO.pm line 29.
======
I run the same command on the same exact file while logged into my other
machine and it works fine. What's going on? How can I fix this?
Help?
Thanks!
Nate.
--
Nathan Gasser LibertyNet
gasser@libertynet.org 3624 Market Street
http://www.libertynet.org/gasser Philadelphia, PA 19104
Visit LibertyNet at http://www.libertynet.org/ (215) 387-6440 ext. 224
------------------------------
Date: 5 Jan 1999 21:22:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: looking for perl programmer
Message-Id: <76tvrd$hqr$1@marina.cinenet.net>
Snowhare (snowhare@devilbunnies.org) wrote:
: In article <36907D62.DD53F1A3@c-zone.net>,
: TRG Software <chatmaster@c-zone.net> wrote:
: >I dont know much about the hardware but its a unix server on the fast
: >connection to the net on a DSL ( faster then a t-3) line you will be
:
: Hmmm...At this level of cluelessness you would expect him to be in
: retail computer sales. :))))
Either that, or I want to move to his phone company's service area!
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "The hills were burning, and the wind was raging; and the
clock struck midnight in the Garden of Allah."
------------------------------
Date: 05 Jan 1999 14:38:23 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: looking for perl programmer
Message-Id: <m3n23x5rjk.fsf@moiraine.dimensional.com>
cberry@cinenet.net (Craig Berry) writes:
> Snowhare (snowhare@devilbunnies.org) wrote:
> : In article <36907D62.DD53F1A3@c-zone.net>,
> : TRG Software <chatmaster@c-zone.net> wrote:
> : >I dont know much about the hardware but its a unix server on the fast
> : >connection to the net on a DSL ( faster then a t-3) line you will be
> :
> : Hmmm...At this level of cluelessness you would expect him to be in
> : retail computer sales. :))))
>
> Either that, or I want to move to his phone company's service area!
US West is advertising 7 mb/s service here (denver, co), which is
faster than a t3. I don't think that that is bidirectional, though.
ObPerl: Ummmm...... US West is doing some of the administrative
stuff for their dsl service using perl scripts, or at least that's
what I've been told (there, now I'm not _completely_ off-topic :-)
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 05 Jan 1999 15:22:53 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: looking for perl programmer
Message-Id: <m3btkd5phe.fsf@moiraine.dimensional.com>
Uri Guttman <uri@ibnets.com> writes:
> >>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
> DG> US West is advertising 7 mb/s service here (denver, co), which is
> DG> faster than a t3. I don't think that that is bidirectional,
> DG> though.
>
> call me wrong but isn't a T3 45Mb/s? which is much faster than any XDSL
> i have ever heard about.
Ack! You're right. I was thinking 4.5Mb/s for some reason.
I will now write `I will think while I type' 2<<31 times as
punishment. :-)
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 05 Jan 1999 17:07:52 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: looking for perl programmer
Message-Id: <39sodpqsp3.fsf@ibnets.com>
>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
DG> cberry@cinenet.net (Craig Berry) writes:
>> Snowhare (snowhare@devilbunnies.org) wrote: : In article
>> <36907D62.DD53F1A3@c-zone.net>, : TRG Software
>> <chatmaster@c-zone.net> wrote: : >I dont know much about the
>> hardware but its a unix server on the fast : >connection to the net
>> on a DSL ( faster then a t-3) line you will be : : Hmmm...At this
>> level of cluelessness you would expect him to be in : retail
>> computer sales. :))))
>>
>> Either that, or I want to move to his phone company's service area!
DG> US West is advertising 7 mb/s service here (denver, co), which is
DG> faster than a t3. I don't think that that is bidirectional,
DG> though.
call me wrong but isn't a T3 45Mb/s? which is much faster than any XDSL
i have ever heard about.
most residential dsl services being offered are ADSL or asymmetric with
a much slower upload link than download. businesses are offered HDSL or
SDSL which are symmetric regarding speeds.
but nothing beats cable modem deal with 1.5Mb/s down and 300Kb/s up for
$40/month.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Tue, 5 Jan 1999 16:15:35 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newline
Message-Id: <7u2u67.6n7.ln@magna.metronet.com>
Lloyd Zusman (ljz@asfast.com) wrote:
: In Perl5, it's better to use `chomp' instead of `chop'. The `chop'
: function strips off the rightmost character of a string no matter
: what, while `chomp' strips it only if it's an end-of-line character.
^^^^^^^^^
Or character_s_.
It removes whatever the current value
of $/ is, which may be more than one character.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Jan 1999 16:08:17 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Opening remote file
Message-Id: <76tv01$5ni@panix.com>
In <76tre0$dc1$1@readme.online.no> "Henrik Ruud" <famruud@online.no> writes:
>How do I open a file from ANOTHER SERVER into a variable in a perl-script?
Your question isn't clear, but the Net::FTP module may be what you are
looking for...
--
Clay Irving
clay@panix.com
------------------------------
Date: Tue, 05 Jan 1999 21:41:05 GMT
From: rmore1@my-dejanews.com
Subject: Order of building a multi-level hash
Message-Id: <76u0tg$sce$1@nnrp1.dejanews.com>
Is there a difference between...
#!/usr/local/bin/perl -w
# Method A
$tree{'Jones'} = "NY";
$tree{'Smith'}{'Bob'} = "CT";
$tree{'Smith'}{'Steve'} = "CA";
$tree{'Smith'} = "NJ";
print "$tree{'Smith'}{'Steve'}\n";
# Method B
$tree1{'Jones'} = "NY";
$tree1{'Smith'} = "NJ";
$tree1{'Smith'}{'Bob'} = "CT";
$tree1{'Smith'}{'Steve'} = "CA";
print "$tree1{'Smith'}{'Steve'}\n";
##### Output
Use of uninitialized value at test.pl line 10.
CA
##########
Method A seems to erase the previous values in the hash array. Is
this correct or a bug perl5 (5.0 patchlevel 4 subversion 4)???
Rich More
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 05 Jan 1999 15:10:55 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Order of building a multi-level hash
Message-Id: <m3g19p5q1c.fsf@moiraine.dimensional.com>
rmore1@my-dejanews.com writes:
> Is there a difference between...
Yes.
> #!/usr/local/bin/perl -w
>
> # Method A
>
> $tree{'Jones'} = "NY";
Associate value `NY' with key `Jones' in $tree.
> $tree{'Smith'}{'Bob'} = "CT";
> $tree{'Smith'}{'Steve'} = "CA";
Associate values `CT' and `CA' with keys `Bob' and `Steve' in the
anonymous hash associated with the key `Smith' in $tree.
> $tree{'Smith'} = "NJ";
Clobber the anonymous hash created on the previous 2 lines by
associating the value `NJ' with `Smith'. $tree{Smith}{Steve}
no longer exists.
> print "$tree{'Smith'}{'Steve'}\n";
This is line 10, and sure enough, you are using an uninitialized
value.
> # Method B
>
> $tree1{'Jones'} = "NY";
Same as above.
> $tree1{'Smith'} = "NJ";
Associate value `NJ' with key `Smith' in $tree1.
> $tree1{'Smith'}{'Bob'} = "CT";
> $tree1{'Smith'}{'Steve'} = "CA";
Clobber value `NJ', replace with a reference to an anonymous
hash.
HTH
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 05 Jan 1999 17:14:52 -0500
From: Uri Guttman <uri@ibnets.com>
To: rmore1@my-dejanews.com
Subject: Re: Order of building a multi-level hash
Message-Id: <39r9t9qsdf.fsf@ibnets.com>
>>>>> "r" == rmore1 <rmore1@my-dejanews.com> writes:
r> # Method A
r> $tree{'Jones'} = "NY";
r> $tree{'Smith'}{'Bob'} = "CT";
r> $tree{'Smith'}{'Steve'} = "CA";
r> $tree{'Smith'} = "NJ";
this overwrites $tree{'Smith'} so Bob and Steve which were in an anon
hash are lost.
r> $tree1{'Jones'} = "NY";
r> $tree1{'Smith'} = "NJ";
r> $tree1{'Smith'}{'Bob'} = "CT";
now Smith doesn't equal 'NJ' but rather an anon hash like { 'Bob' => 'CT' }
you just dont try to print it and it is as lost as the method A example
r> Method A seems to erase the previous values in the hash array. Is
r> this correct or a bug perl5 (5.0 patchlevel 4 subversion 4)???
highly doubtful (positively) that is a bug with such a basic semantic
op. it is your misunderstanding of multilevel hashes which is at fault.
a given hash entry at any level can only store a single scalar
value. multilevel hashes are made by having that scalar value be a
reference to an anon hash. so $tree{'Smith'} can't store both
'NJ' and { 'Bob' => 'CT' }.
choose one or the other.
and read the perldsc doc and the perl cookbook for more on this.
hth,
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 6 Jan 1999 08:45:30 +1100
From: "Bob Reynolds" <Bob@b-tech.net>
Subject: Perl + Excel OLE
Message-Id: <76u1bh$4k3$1@news0-alterdial.uu.net>
Hi Guys,
Been looking all over the net looking for the method to detect if an excel
spread sheet is open or not.
I have some scripts that grab data from all over the place, manipulate and
throw it into an excel sheet then print reports from this sheet... trouble
is at the end of the run, the sheet has to save, and if someone else is
looking at the raw data for whatever reason, the box the reports run on pops
the save as dialogue becuase the spreasheet was opened in read only mode...
so.. does anyone know the ole method to detect if the file was already
opened by someone else??
TIA
Bob Reynolds.
------------------------------
Date: Tue, 05 Jan 1999 22:40:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERL and permissions
Message-Id: <3692839c.2544345@news.skynet.be>
Alejandro Eluchans wrote:
>Does any body know how to change the permission of a PERL script from
>nobody to a user with full privileges in a particular directory in order
>to edit and create files using PERL without having to give full
>permission to nobody.
The magic word is: SUID or Set-UID ("set user ID"). Maybe look it up. It
can let user "nobody" run this one particular script as if he was you.
Er... "the owner of the script".
It involves setting one bit in the file's access properties. You need to
do this using Telnet, 'cos (AFAIK) no FTP client lets you do this.
It's a bit hairy, though. In short: expect trouble.
HTH,
Bart.
------------------------------
Date: Tue, 05 Jan 1999 16:09:20 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Perl CD Bookshelf plans
Message-Id: <36927F80.17FFF055@perspex.com>
Chris Maden wrote:
> _Advanced Perl Programming_
> _Perl Cookbook_
> _Programming Perl_
> _Perl in a Nutshell_
> _Perl 5 Pocket Reference_
I'd pay more to see these books on a single CD:
Advanced Perl Programming
Perl Cookbook
Programming Perl
Mastering Regular Expressions
Effective Perl Programming*
<as-yet unwritten "masters" book on Perl/Tk>
Perl in a Nutshell
* Okay, okay, I'm being funny here... but if you /could/ work out a
license with AWL, that would rock.
I'm really not sure why you're including any of the Pocket References...
Do that add any value to the existing books? In the dead-tree world, their
value is that they are pocket-sized and highly portable. Isn't the CD this
by itself?
I have a similar feeling about Perl in a Nutshell, but in looking over the
TOC from the website, it looks like it covers some areas not yet
exhaustively documented by other ORA books. Thus it does go on the list,
but down at the bottom.
------------------------------
Date: 05 Jan 1999 23:16:14 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Chris Maden <crism@oreilly.com>
Subject: Re: Perl CD Bookshelf plans
Message-Id: <m3d84tnz69.fsf@joshua.panix.com>
Chris Maden <crism@oreilly.com> writes:
> Would an expert be annoyed at search hits coming up in the
> introductory books?
Why not just have the search engine include checkboxes for each title
to be searched?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 05 Jan 1999 15:31:41 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Perl CD Bookshelf plans
Message-Id: <m37lv15p2q.fsf@moiraine.dimensional.com>
Jonathan Feinberg <jdf@pobox.com> writes:
> Chris Maden <crism@oreilly.com> writes:
>
> > Would an expert be annoyed at search hits coming up in the
> > introductory books?
>
> Why not just have the search engine include checkboxes for each title
> to be searched?
This is a perl collection. Why not have a CD::Search module and
let me decide how I want to have hits displayed.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Tue, 5 Jan 1999 14:46:20 -0800
From: "Adi Mishra" <mishra.aditya@emeryworld.com>
Subject: Re: Question: How to spawn another program and then die
Message-Id: <76u48v$goq@news.cnf.com>
perldoc -f fork
------------------------------
Date: Tue, 05 Jan 1999 21:19:12 +0100
From: Christoph Wernli <cw@dwc.ch>
To: Aidan Rogers <aidan@salvador.blackstar.co.uk>
Subject: Re: Quick operator question
Message-Id: <369273C0.178640C0@dwc.ch>
Aidan Rogers wrote:
>
> Is there a quicker way to do the following?
>
> $foo = 50 if $foo > 50;
$foo > 50 ? $foo = 50 : 1 ;
Quicker ? You;ld have to timeit.
-w
------------------------------
Date: Tue, 5 Jan 1999 21:11:27 GMT
From: Darrin Edwards <d-edwards@nospam.uchicago.edu>
Subject: Re: sort hash by values
Message-Id: <tglnjhifwg.fsf@noise.bsd.uchicago.edu>
Ying Hu <yhu@mail.nih.gov> writes:
> I do not know why the following scritpe did not work. Help, please.
> I want sort values (number) of hash.
> while (($key, sort {$a<=>$b}$value) = each %my_hash){
> &doing_something;
> }
What error message do you get? When I try this (or something
very like it), I get:
:Can't modify sort in list assignment at -e line 5, near "%my_hash)"
:Execution of -e aborted due to compilation errors.
(Your line numbers and executable names may vary of course.)
Did you try getting more information about that error
message by looking it up with 'perldoc perldiag'?
Did you look up 'each' in the perl documentation? (perldoc -f each)
Did you look up 'sort' in the perl documentation? (perldoc -f sort)
Do you understand why you can't assign to 'sort'?
Did you read the section in perlfaq4 entitled 'How do I sort a hash
(optionally by value instead of key)?'
Cheers,
Darrin
------------------------------
Date: Tue, 5 Jan 1999 16:20:50 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sort hash by values
Message-Id: <283u67.6n7.ln@magna.metronet.com>
Ying Hu (yhu@mail.nih.gov) wrote:
: I wanted as the following:
: foreach $key (keys %hash_sorted_by_their_values){
: @doing;
: }
Well good!
Because that is exactly what Staffan gave you...
: Staffan Liljas wrote:
: > foreach $key (sort { $hash{$b} <=> $hash{$a} } keys %hash)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Jan 1999 20:38:02 +0000
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
Subject: subroutine declaration in a loop and lexical variables
Message-Id: <u93e5ptpzp.fsf@wcl-l.bham.ac.uk>
The script:
#!/usr/bin/perl -w
use strict;
my $i;
while ( $i++ < 3 ) {
my $j = $i;
sub foo { print "\$i=$i \$j=$j\n" };
foo;
}
On perl5 (5.0 patchlevel 4 subversion 4) generates:
$i=1 $j=1
$i=2 $j=1
$i=3 $j=1
I think thI can see why this is happening but I'd like to know if this
is considered a bug. And if it's not considered a bug I think it
would be nice if it emitted a warning.
------------------------------
Date: 05 Jan 1999 22:50:06 +0100
From: Roland Huss <roland.huss@consol.de>
Subject: Re: subroutine returning an lvalue
Message-Id: <rvcsodppey9.fsf@trurl.int.consol.de>
Brett Diamond <Brett.Diamond@lmco.com> writes:
> I'd like to create a subroutine that works like the Perl "substr"
> builtin,
> where I can both use it both as an rvalue and an lvalue.
> .
> .
> $my_dept->Budget() = 1000000;
What so bad about
$my_dept->{Budget} = 1000000;
or
$my_dept->Budget(10000);
?
( I know, that's not the answer you are looking for, however I'm
simply curious...)
--
...roland
------------------------------
Date: Tue, 05 Jan 1999 21:57:16 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Web server in perl
Message-Id: <slrn7952mj.88.alastair@calliope.demon.co.uk>
Andy Davidson <pheon@hevanet.com> wrote:
>Is there a web server in perl? I am in need of very simple server for
>use on isloated laptops where I would like to add some form processing
>to a set of pages. Has anyone done this? I couldn't find anything
>searching CPAN et al.
HTTPi is a perl web server ;
http://stockholm.ptloma.edu/httpi/
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 5 Jan 1999 22:13:29 +0100
From: "Meint Post" <meint.post@tref.nl>
Subject: Re: which database to take for perl + tk + win32?
Message-Id: <76tvcc$oee$1@rubens.telebyte.nl>
Hi Juergen,
>I want to rewrite an old dBASE program with perl and tk. I looked at
Win32::ODBC
>which seems to give access to some .dbm files. Now I am stuck putting the
things
>togetner. Is it a good way to reuse the old .dbf files with odbc, or would
it be
>better to use another database (is there anything freely available for
windows
>nt?)
Why not use DBD::XBase - DBI driver for XBase compatible database files ?
You can get the module from activestate with ppm. I Haven't used it but I am
a great believer of the DBI model so I suggest you give it a try.
hth
Meint
--
Hilta Goatfounder was all lace and shawls and colours
and earrings and so many bangles that a mere movement
of her arms sounded like a percussion section falling off a cliff.
------------------------------
Date: Tue, 05 Jan 1999 21:41:58 GMT
From: vcuya@mindspring.com (Victor A. Cuya)
Subject: Win32::AdminMisc::LogonAsUser... Any success?
Message-Id: <369283fa.14566515@news.mindspring.com>
Has anyone used the above mentioned function call successfully in a
PDC environment? If so, what were the steps to accomplish it?
Did you have to setup a special user account?
Did you need to run the 'su' service from the ResKit?
I have followed the instructions in the documentation to no avail. Any
suggestions will be greatly appreciated.
Victor A. Cuya
------------------------------
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 4558
**************************************