[9246] in Perl-Users-Digest
Perl-Users Digest, Issue: 2841 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 11 13:17:24 1998
Date: Thu, 11 Jun 98 10:01:41 -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 Thu, 11 Jun 1998 Volume: 8 Number: 2841
Today's topics:
Re: perl locales in RH 5.1 <rootbeer@teleport.com>
Re: Perl to C translator <dean@mail.biol.sc.edu>
Re: Perl to C translator <robsmith@writeme.com>
Re: Problem with some s/// code (Patrick Timmins)
Re: Problem with some s/// code (Patrick Timmins)
Re: Problem with some s/// code (Mike Wescott)
Re: Return characters from a string (Tom Harrington)
Scoping question (Malcolm Hoar)
Re: Scoping question <tchrist@mox.perl.com>
Re: Scoping question <jdf@pobox.com>
Re: sendmail on NT IIS4 scott@softbase.com
Re: Sorry for seperate posts <robsmith@writeme.com>
Re: Stages in a pipeline <jdporter@min.net>
Re: taking data out of ':' delimited string and placing <rootbeer@teleport.com>
Re: taking data out of ':' delimited string and placing (Tom Harrington)
Re: Test running PERL script in Windows 95 holgerman@my-dejanews.com
Using SDBM and Hashes of Hashes. Is it possible? How? <jp@dkstat.com>
Re: Vote today, read CFV for c.l.p.moderated, Post the (Greg Bacon)
Re: Where is the robot? <dgraff@computex.com>
Re: Why doesn't this work? <jdf@pobox.com>
Re: Why it's stupid to `use a variable as a variable na <PROCURA_BV@CompuServe.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Jun 1998 16:28:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl locales in RH 5.1
Message-Id: <Pine.GSO.3.96.980611091108.5401g-100000@user2.teleport.com>
On Thu, 11 Jun 1998, Ben Sandler wrote:
> I just installed RedHat 5.1 with perl 5.004, and whenever I run a perl
> script, the output is prefaced by the following:
>
> perl: warning: Setting locale failed.
I'm appending some information from the perllocale manpage. (Your
perllocale manpage may not (yet) have this information, which was just
recently added.) Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
=head2 LOCALE PROBLEMS
You may meet the following warning message at Perl startup:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = "En_US",
LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
This means that your locale settings were that LC_ALL equals "En_US"
and LANG exists but has no value. Perl tried to believe you but it
could not. Instead Perl gave up and fell back to the "C" locale, the
default locale that is supposed to work no matter what. This usually
means either or both of the two problems: either your locale settings
were wrong, they talk of locales your system has never heard of, or
that the locale installation in your system has problems, for example
some system files are broken or missing. For the problems there are
quick and temporary fixes and more thorough and lasting fixes.
=head2 Temporarily fixing locale problems
The two quickest fixes are either to make Perl be silent about any
locale inconsistencies or to run Perl under the default locale "C".
Perl's moaning about locale problems can be silenced by setting the
environment variable PERL_BADLANG to a non-zero value, for example
"1". This method really just sweeps the problem under the carpet: you
tell Perl to shut up even when Perl sees that something is wrong. Do
not be surprised if later something locale-dependent works funny.
Perl can be run under the "C" locale by setting the environment
variable LC_ALL to "C". This method is perhaps a bit more civilised
than the PERL_BADLANG one but please note that setting the LC_ALL (or
the other locale variables) may affect also other programs, not just
Perl. Especially external programs run from within Perl will see
these changes. If you make the new settings permanent (read on), all
the programs you run will see the changes. See L<ENVIRONMENT> for for
the full list of all the environment variables and L<USING LOCALES>
for their effects in Perl. The effects in other programs are quite
easily deducible: for example the variable LC_COLLATE may well affect
your "sort" program (or whatever the program that arranges `records'
alphabetically in your system is called).
You can first try out changing these variables temporarily and if the
new settings seem to help then put the settings into the startup files
of your environment. Please consult your local documentation for the
exact details but very shortly for UNIXish systems: in Bourneish
shells (sh, ksh, bash, zsh) for example
LC_ALL=en_US.ISO8859-1
export LC_ALL
We assume here that we saw with the above discussed commands the
locale "en_US.ISO8859-1" and decided to try that instead of the above
faulty locale "En_US" -- and in Cshish shells (csh, tcsh)
setenv LC_ALL en_US.ISO8859-1
If you do not know what shell you have, please consult your local
helpdesk or the equivalent.
=head2 Permanently fixing locale problems
Then the slower but better fixes: the misconfiguration of your own
environment variables you may be able to fix yourself; the
mis(sing)configuration of the whole system's locales usually requires
the help of your friendly system administrator.
First, see earlier in this document about L<Finding locales>. That
tells how you can find which locales really are supported and more
importantly, installed, in your system. In our example error message
the environment variables affecting the locale are listed in the order
of decreasing importance and unset variables do not matter, therefore
in the above error message the LC_ALL being "En_US" must have been the
bad choice. Always try fixing first the locale settings listed first.
Second, if you see with the listed commands something B<exactly> (for
example prefix matches do not count and case usually matters) like
"En_US" (without the quotes), then you should be okay because you are
using a locale name that should be installed and available in your
system. In this case skip forward to L<Fixing the system locale
configuration>.
=head2 Permantently fixing your locale configuration
This is the case when for example you see
perl: warning: Please check that your locale settings:
LC_ALL = "En_US",
LANG = (unset)
are supported and installed on your system.
but then cannot see that "En_US" listed by the above-mentioned
commands. You may see things like "en_US.ISO8859-1" but that is not
the same thing. In this case you might try running under a locale
that you could list and somehow matches with what you tried. The
rules for matching locale names are a bit vague because
standardisation is weak in this area. See again the L<Finding
locales> about the general rules.
=head2 Permanently fixing the system locale configuration
Please contact your system administrator and tell her the exact error
message you get and ask her to read this same documentation you are
now reading. She should be able to check whether there is something
wrong with the locale configuration of the system. The L<Finding
locales> section is unfortunately a bit vague about the exact commands
and places because these things are not that standardised.
------------------------------
Date: 10 Jun 1998 12:25:22 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
Subject: Re: Perl to C translator
Message-Id: <m3pvghtea5.fsf@mail.biol.sc.edu>
"N Maderna" <nmaderna@nospam.co.uk> writes:
> Probably this question has been made thousands of times, but ... Does a Perl
> to C translator exist???? and if it does where do I get it?
Good guess. Why, then, did you post this to Usenet instead of
checking the FAQ list at http://www.perl.com (which a trivial use of
any WWW search engine would have found for you)?
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Wed, 10 Jun 1998 14:49:25 -0400
From: "Rob Smith" <robsmith@writeme.com>
Subject: Re: Perl to C translator
Message-Id: <6lmkkp$dee$1@snoopy.uscsumter.edu>
Dean,
Why is it necessary to be so rude? Not only have you ruined your
reputation, but you have also attached USC to your remark...
It was an honest question...
Dean Pentcheff wrote in message ...
>"N Maderna" <nmaderna@nospam.co.uk> writes:
>> Probably this question has been made thousands of times, but ... Does a
Perl
>> to C translator exist???? and if it does where do I get it?
>
>Good guess. Why, then, did you post this to Usenet instead of
>checking the FAQ list at http://www.perl.com (which a trivial use of
>any WWW search engine would have found for you)?
>
>-Dean
>--
>N. Dean Pentcheff
<pentcheff@acm.org>
>Biological Sciences, Univ. of South Carolina, Columbia SC 29208
(803-777-7068)
------------------------------
Date: Thu, 11 Jun 1998 14:49:24 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Problem with some s/// code
Message-Id: <6loqpk$jsj$1@nnrp1.dejanews.com>
In article <6loink$8p4$1@nnrp1.dejanews.com>,
dejajustin@my-dejanews.com wrote:
>
> Does anyone see anything wrong with this line of code?
> $outline=~s/\((\d)\) /\($1\)\[nb\]/g; #replace "(digit) " with "(digit)[nb]"
>
> it needs to turn any space follwing a single digit in parens into "[nb]"..
>
> any suggestions would be much appreciated..
>
> -Justin
You have a white space just in front of the '/' terminating your pattern to
match. Get rid of it:
$outline=~s/\((\d)\)/\($1\)\[nb\]/g; #replace "(digit) " with "(digit)[nb]"
This works. Of course this will only match things with one digit like '(3)' or
'(7)'. For a more general solution (more than one digit) you would add a '+'
after the '\d' in your pattern:
$outline=~s/\((\d+)\)/\($1\)\[nb\]/g; #replace "(digit) " with "(digit)[nb]"
Hope that helps.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 11 Jun 1998 14:58:54 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Problem with some s/// code
Message-Id: <6lorbe$kna$1@nnrp1.dejanews.com>
In article <6loink$8p4$1@nnrp1.dejanews.com>,
dejajustin@my-dejanews.com wrote:
>
> Does anyone see anything wrong with this line of code?
> $outline=~s/\((\d)\) /\($1\)\[nb\]/g; #replace "(digit) " with "(digit)[nb]"
>
> it needs to turn any space follwing a single digit in parens into "[nb]"..
>
> any suggestions would be much appreciated..
>
> -Justin
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
>
Whoops! disregard my other post. You specifically said you wanted the white
space to be replaced with "[nb]". I was thinking you just wanted to tag it on
to the end. In this case, your code looks fine to me. You could tag a '+' on
to the '\d' in your pattern so that you can match more than just single digit
numbers ( eg: would be able to match "(234) " or "(98) " or "(3) ", instead
of just "(3) " or "(7) " ).
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 11 Jun 1998 12:21:15 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
To: dejajustin@my-dejanews.com
Subject: Re: Problem with some s/// code
Message-Id: <x4wwanvrid.fsf@cygnus.ColumbiaSC.NCR.COM>
In article <6loink$8p4$1@nnrp1.dejanews.com> dejajustin@my-dejanews.com writes:
> Does anyone see anything wrong with this line of code?
> $outline=~s/\((\d)\) /\($1\)\[nb\]/g; #replace "(digit) " with "(digit)[nb]"
> it needs to turn any space follwing a single digit in parens into "[nb]"..
Looks fine to me. Does what I expect it to do. So maybe the problem
is that $outline doesn't have anything in it for s/.../.../ to operate
on.
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 11 Jun 1998 15:45:21 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: Return characters from a string
Message-Id: <6lou2h$j6a5@eccws1.dearborn.ford.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: In article <6lm9gu$3u94@eccws1.dearborn.ford.com>, tph@longhorn.uucp
: says...
: > I would have done it this way:
: >
: > ($piece = $string) =~ s/^(.{22}).*/$1/;
: >
: > ...but maybe I'm just weird...
: ...
: Not weird, just slow. Very slow. TMTOWTDI, but they're not all "created
: equal."
Thanks, I had no idea. The regexp approach "felt" better, but if it's
that much slower then I need to adjust my attitude a bit.
--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
"It is not I who am crazy... It is I who am MAD!..." -Ren & Stimpy
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx
------------------------------
Date: Thu, 11 Jun 1998 15:26:51 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: Scoping question
Message-Id: <6losvp$5bi$1@nntp1.ba.best.com>
I am very confused by the following; specifically the fact
that @XX::Array appears to be modified on each call to &Test.
I've studied the Camel but still need a clue :-( TIA.
#!/usr/local/bin/perl -w
use strict;
package XX;
@XX::Array = ("abc", "def", "ghi");
&Test ("123");
&Test ("456");
&Test ("789");
exit;
sub Test {
use strict;
my ($num) = @_;
my ($try);
foreach $try (@XX::Array) {
print "NUM $num TRY $try\n";
$try = "$num$try";
if ($try eq "xyz") {$num = $try; return ($try); }
}
return ();
}
perl -w t.pl
NUM 123 TRY abc
NUM 123 TRY def
NUM 123 TRY ghi
NUM 456 TRY 123abc
NUM 456 TRY 123def
NUM 456 TRY 123ghi
NUM 789 TRY 456123abc
NUM 789 TRY 456123def
NUM 789 TRY 456123ghi
perl -v
This is perl, version 5.004_04 built for i386-freebsd
--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar "The more I practice, the luckier I get". |
| malch@malch.com Gary Player. |
| http://www.malch.com/ Shpx gur PQN. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 11 Jun 1998 15:41:37 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Scoping question
Message-Id: <6lotrh$cpi$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
malch@malch.com (Malcolm Hoar) writes:
:I am very confused by the following; specifically the fact
:that @XX::Array appears to be modified on each call to &Test.
:I've studied the Camel but still need a clue :-( TIA.
: foreach $try (@XX::Array) {
: $try = "$num$try";
% man perlsyn
[...]
If any element of LIST is an lvalue, you can modify it by modifying
VAR inside the loop. That's because the foreach loop index variable
is an implicit alias for each item in the list that you're looping
over.
This is by design.
--tom
--
When in doubt, parenthesize. At the very least it will let some
poor schmuck bounce on the % key in vi.
--Larry Wall in the perl man page
------------------------------
Date: 11 Jun 1998 11:54:48 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: malch@malch.com (Malcolm Hoar)
Subject: Re: Scoping question
Message-Id: <vhq7najr.fsf@mailhost.panix.com>
malch@malch.com (Malcolm Hoar) writes:
> I am very confused by the following; specifically the fact
> that @XX::Array appears to be modified on each call to &Test.
> I've studied the Camel but still need a clue :-( TIA.
[snip]
> foreach $try (@XX::Array) {
[snip]
> if ($try eq "xyz") {$num = $try; return ($try); }
> }
As documented in the Camel and in perlsyn, the loop variable (in this
case, "$try") in a foreach loop is actually an alias to the array
element that you're examining in a given loop iteration. If you mess
with the alias, you're really messing with the array element.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 11 Jun 1998 14:26:18 GMT
From: scott@softbase.com
Subject: Re: sendmail on NT IIS4
Message-Id: <6lopea$3j6$2@mainsrv.main.nc.us>
scott@softbase.com wrote:
> I use a function called smtpmail which I wrote that works with
> both UNIX-based sendmail mailers and Exchange servers. I posted
> this function just a few days ago, so it should be easy to find.
By popular demand, here it is again. Below the sig.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
######################################################################
# smtpmail
#
# WARNING: Please tailor the variables $whoami and $remote in this
# function to match the host running this script and your
# SMTP server respectively.
#
# This function has been specifically developed to work with
# Microsoft Exchange Server 5.0's Internet Mail Service. It is based
# on the typical UNIX-based Perl code for an SMTP transaction.
#
# You pass this subroutine the e-mail address to send the message
# to, the subject of the message, and an array of strings that
# makes up the body of the message. The common idiom to build the
# array of strings is to push a string onto the array every time
# you would print out (or in addition to printing out) information
# to the console.
######################################################################
sub smtpmail {
my ($to, $subj, @msg) = @_;
my ($whoami, # the name of your computer
$remote, # the name of the SMTP server
$port, # the mail port
$iaddr, $paddr, $proto, $line); # these vars used internally
$whoami = "garbage.trashcan.com";
$remote = 'mailbox.trashcan.com';
$port = 25;
$iaddr = inet_aton($remote) || die "no host: $remote";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
select(SOCK);
$| = 1;
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
# The sleeps in this transaction are necessary in order to let
# the Exchange server work with your
print SOCK "HELO $whoami\n";
sleep(5);
print SOCK "MAIL FROM: backup\n";
sleep(5);
print SOCK "RCPT TO: scott\@softbase.com\r\n";
sleep(5);
print SOCK "DATA\n";
print SOCK "From: scott\@softbase.com\n";
print SOCK "Subject: $subj\n";
print SOCK "To: $to\n";
print SOCK "\n";
print SOCK @msg;
print SOCK "\n.\n";
sleep(5);
print SOCK "QUIT\n";
sleep(5);
close (SOCK) || die "close: $!";
}
------------------------------
Date: Wed, 10 Jun 1998 14:55:36 -0400
From: "Rob Smith" <robsmith@writeme.com>
Subject: Re: Sorry for seperate posts
Message-Id: <6lml0c$do2$1@snoopy.uscsumter.edu>
Also look at http://www.ora.com
------------------------------
Date: Thu, 11 Jun 1998 14:57:03 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Stages in a pipeline
Message-Id: <357FF1B9.3F03@min.net>
Scott Bronson wrote:
>
> I've got a bunch of fucntions. All of them accept data as an argument,
> process it, and return the processed data as their result. The data is
> an array of lines, but that should be unimportant.
>
> Print -> Format_Lists -> Number_Lines -> Remove_Header -> Get_Paragraph
I don't think it gets any elaganter than this:
sub Format_Lists {
# input is found in @_
# output is a returned list of values
}
sub Number_Lines {
my $n = 0;
map { $n++; "$n: $_" } @_;
}
sub Remove_Header {
my @lines = @_;
shift @lines while is_headerline( $lines[0] );
@_;
}
sub Get_Paragraph {
local $/ = "";
split( /\n/, scalar(<>) );
}
print Format_Lists( Number_Lines( Remove_Header( Get_Paragraph() ) ) );
This works in a very functional way, using no state external
to the pipeline (except for that diamond operator in Get_Paragaph :-)
Clearly, what these functions actually do is up to you.
I didn't write sub is_headerline; you can, if you like.
hth,
John Porter
------------------------------
Date: Thu, 11 Jun 1998 16:35:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: taking data out of ':' delimited string and placing it into 6 variables
Message-Id: <Pine.GSO.3.96.980611093123.5401h-100000@user2.teleport.com>
On Thu, 11 Jun 1998, Azman Shariff wrote:
> data :
> roger:1002:10004:Roger Deng:/home/roger:/bin/bash
>
> looks familiar huh? .. .yepp it is from my passwd file.... i need to
> write code to takethe six fields and put them in diff variables
Others have suggested ways you could parse this data. But maybe it would
help to know that Perl provides access to the system calls which can get
this information directly. (In fact, the system calls are even better than
reading /etc/passwd, because the system calls should be set up to find
this information even if you're using NIS, for example.) See the getpw*
calls in perlfunc and in your system's manpages. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 Jun 1998 16:04:10 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: taking data out of ':' delimited string and placing it into 6 variables
Message-Id: <6lov5q$j6a7@eccws1.dearborn.ford.com>
Azman Shariff (azman@bnex.com) wrote:
: data :
: roger:1002:10004:Roger Deng:/home/roger:/bin/bash
<snip>
: ($fielduname, $fielduid, $fieldgid, $fieldfullname, $fieldhome,
: $fieldshell) = split(/:/,$_,6);
: doesn't seem to work though..
% perl
$_ = "roger:1002:10004:Roger Deng:/home/roger:/bin/bash\n";
($fielduname, $fielduid, $fieldgid, $fieldfullname,
$fieldhome,$fieldshell) = split(/:/,$_,6);
print "$fielduname, $fielduid, $fieldgid, $fieldfullname, $fieldhome,$fieldshell\n";
__END__
roger, 1002, 10004, Roger Deng, /home/roger,/bin/bash
What seems to go wrong in your script? Are you sure the data is
in $_?
--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
Small forest creatures have become one with their surroundings due to
Hand Grenades. -"MAKE FRAGMENTS FAST", by deton@te.com
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx
------------------------------
Date: Thu, 11 Jun 1998 15:21:48 GMT
From: holgerman@my-dejanews.com
Subject: Re: Test running PERL script in Windows 95
Message-Id: <6losmc$mi4$1@nnrp1.dejanews.com>
In article <357CF83E.78E24BD1@ipacs.com>,
Ong Joo Chin <jcong@ipacs.com> wrote:
>
> Currently, I am writing my PERL CGI script in my Windows 95 machine
> follow by FTP to the remote site. In this way, I can't test out my
> script. Can anybody advise me how to write PERL script and test run in
> my Window 95 machine with Netscape browser before FTP to the remote
> site.
If you have Windows 95 with Personal Webserver, you want to download and
install ActiveState's Perl for Win32 (http://www.ActiveState.com/) and then
read the FAQ on how to set up Perl on Personal Webserver:
http://www.ActiveState.com/support/faqs/Perl_for_Win32_FAQ_6.html#6_7
That will give you a nice test environment as well as the option to run your
Perl scripts from the MS-DOS prompt for debugging. However, if your final
target OS is UNIX, be aware that there a number of differences between the
WIN and UNIX implementations (functions not supported by Perl for Windows as
well some other stuff).
Hope that helps,
Bjoern
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 11 Jun 1998 09:08:51 -0700
From: jp <jp@dkstat.com>
Subject: Using SDBM and Hashes of Hashes. Is it possible? How?
Message-Id: <35800113.EFA35BF2@dkstat.com>
Hi there:
I'm trying to use SBDM to store Hashes of Hashes. Is this possible?
When I store only a Hash the keys and values are returned no problem.
------------------------------------
#storeit.pl
------------------------------
use SDBM_File;
dbmopen(%dick,"test",0644) || die "dbmopen failed";
$dick{"key1"}="value1";
dbmclose(%dick);
---------------------------------------
#getit.pl
--------------------------------------------------------
use SDBM_File;
dbmopen(%dick,"test",0644) || die "dbmopen failed";
while (($key,$value) = each(%dick))
{
print "$key : $value\n";
}
dbmclose(%dick);
-------------------------------------------
But if i try to store a hash of hashes my values arent' returned.
------------------------------------
#storeit2.pl
------------------------------
use SDBM_File;
dbmopen(%DBM,"test",0644) || die "dbmopen failed";
$DBM{"1"}{"client"}="joke";
dbmclose(%DBM);
---------------------------------------
#getit.pl
--------------------------------------------------------
use SDBM_File;
dbmopen(%DBM,"test",0644) || die "dbmopen failed";
foreach $family ( keys %DBM) {
print "$family: ";
for $role ( keys %{ $DBM{$family} } ) {
print "$role=$DBM{$family}{$role} ";
} print "\n";}
dbmclose(%DBM);
------------------------------
Date: 11 Jun 1998 14:50:55 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Vote today, read CFV for c.l.p.moderated, Post the CFV here today,
Message-Id: <6loqsf$ajj$7@info.uah.edu>
In article <357FE325.4937@erols.com>,
Ngouah A Nguiamba <ngouah@erols.com> writes:
: Please post the CFV in comp.lang.perl.misc today. One can
: easily overlook the post done to news.groups, as I did.
No!!! Everyone, please do not distribute the CFV in any way!!! If you
want a ballot, you have two options:
1) Hunt through Deja News for
Subject: CFV: comp.lang.perl.moderated moderated
The article was posted to news.groups and comp.lang.perl.misc.
2) Rebecca McQuitty, a member of the Usenet Volunteer Votetakers, is
handling this CFV. You may request a ballot from her by email; her
address is mcq@best.com.
The voting procedure is very clear about not distributing or campaigning
during a voting period. Distributing ballots may result in cancellation
of those resulting votes or the entire CFV. Please do not cause
countless hours of effort to be wasted.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 11 Jun 1998 12:24:23 -0400
From: David Graff <dgraff@computex.com>
Subject: Re: Where is the robot?
Message-Id: <358004B6.11AA2A4E@computex.com>
Ok i'm a newbie on the group and should be ogg'ed for this...i'm
lost...what's the point of this? *laughing nervously at other
responses*
F.Quednau wrote:
> If I'd say to you:
>
> open (THEBOTTLE, "< $with_a_screwdriver"); #!!!
>
> Would you really do it?
>
> --
> ____________________________________________________________
> Frank Quednau
> http://www.surrey.ac.uk/~me51fq
> ________________________________________________
--
****************************************************************
David J. Graff International CompuTex, Inc.
mailto:dgraff@computex.com Phone: (770) 953-1464
Direct: (770) 240-2289 Fax: (770) 953-1574
****************************************************************
------------------------------
Date: 11 Jun 1998 11:50:42 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Dave" <hannum@oak.cat.ohiou.edu>
Subject: Re: Why doesn't this work?
Message-Id: <yav3naql.fsf@mailhost.panix.com>
"Dave" <hannum@oak.cat.ohiou.edu> writes:
> my $query =<<EndOfQuery;
> select *
> from $table
> EndOfQuery
Are you sure you're using perl 5? Have you used the -w switch to
catch any possible typos before that line?
> print header, popup_menu(-name => 'popup', -values = [@array],
^^^
oops, you mean =>
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Thu, 11 Jun 1998 17:08:46 +0200
From: "H.Merijn Brand" <PROCURA_BV@CompuServe.com>
Subject: Re: Why it's stupid to `use a variable as a variable name'
Message-Id: <357FF2FE.355AD484@CompuServe.com>
Mark-Jason Dominus wrote:
> :
> :
> The main point of this article was to present a real example of a case
> where using a variable as a variable name was a really stupid thing to
> do. Since most of the people who post about that in
> comp.lang.perl.misc seem to be trying to do the same stupid thing in
> the same stupid way, I thought I'd mention it, and maybe raise the
> general awareness of this problem.
Good point here. There's one point I like to mention in favour of
soft-refs: If you check the name of the softref BEFORE actualy
asigning a value to it, you can use 'reset'.
In a program previously written in RPT that spanned far over 1500
lines of code, rewriting that to perl gave the same possibilities
in less than 50 lines (which now has grown to over 350, but that's
not the point here).
Checking on input lines, data is stored in variables that start with
a letter (well chosen AND documented) that gives them a special
scope to the whole program. Variables starting with i.e. "e" can be
resetted at some level, while "f" variables have a longer life-cycle.
It would be possible to use separate hashes $e{}, $f{} and so on,
but this would greatly decrease legibility. $e010240 does mean a
lot to the people that create the "format" part of the program,
which is required in the main line. People writing and maintaining
those format scripts are likely NEVER to see the mainline NOR the
way `their' variables are created.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
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 2841
**************************************