[15469] in Perl-Users-Digest
Perl-Users Digest, Issue: 2879 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 27 14:09:55 2000
Date: Thu, 27 Apr 2000 11:05:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956858722-v9-i2879@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 27 Apr 2000 Volume: 9 Number: 2879
Today's topics:
A script to make the output of "perldoc -f ..." more re <franl-removethis@world.omitthis.std.com>
Re: Any electronic perl book to share (pdf will be a bo <makarand_kulkarni@My-Deja.com>
Automated FTP program - anyone have one written? <jeffahill@lucent.com>
Re: Automated FTP program - anyone have one written? <rootbeer@redcat.com>
Re: Automated FTP program - anyone have one written? <gerard@NOSPAMlanois.com>
Re: changing first character of string to upper case <andrew.mcguire@walgreens.com>
Re: changing first character of string to upper case <adrian.clark@gecm.com>
Re: changing first character of string to upper case <andrew.mcguire@walgreens.com>
Re: closing cursors with DBD::Oracle mchavel@kenan.com
Combining strings = Win32::OLE=HASH b_stark@my-deja.com
data base site content <shadsluiter@my-deja.com>
Re: data base site content <rootbeer@redcat.com>
Re: Disk Space <peter_gonnissenNOpeSPAM@euroseek.com.invalid>
Eliminate duplicates from big file <samay1NOsaSPAM@hotmail.com.invalid>
Re: Eliminate duplicates from big file <anfi@bigfoot.com>
Re: Eliminate duplicates from big file <rootbeer@redcat.com>
Re: Eliminate duplicates from big file nobull@mail.com
Re: Eliminate duplicates from big file <sariq@texas.net>
Fast way to do nslookup? <engbpa@liquidinformation.com>
Re: Fast way to do nslookup? <tony_curtis32@yahoo.com>
GPIB <dave_zempel@radixtek.com>
Hashes -- case insensitive keys? (J. B. Moreno)
Re: Hashes -- case insensitive keys? <eryq@zeegee.com>
Re: Hashes -- case insensitive keys? <bmb@ginger.libs.uga.edu>
Re: help with a request <lr@hpl.hp.com>
Re: Hiding Password <rootbeer@redcat.com>
Re: how to close a subrutine <andersen+@rchland.ibm.com>
Re: how to close a subrutine <tony_curtis32@yahoo.com>
Re: how to close a subrutine <andrew.mcguire@walgreens.com>
Re: how to close a subrutine <andrew.mcguire@walgreens.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Apr 2000 18:01:33 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
Subject: A script to make the output of "perldoc -f ..." more readable.
Message-Id: <m3wvljjude.fsf@franl.andover.net>
This script arranges to feed the output of "perldoc -f ..." through
pod2man to make it more readable.
It is UNIX-centric because it depends on UNIX shell quoting semantics,
nroff, and less. If you don't have less installed, change "less" to
"more".
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.
#!/usr/bin/perl
use strict;
use POSIX;
my $tmpdir = POSIX::tmpnam();
my $tmpfile = "$tmpdir/$ARGV[0]";
my $pager = "less";
mkdir($tmpdir, 0755) or die("mkdir failed: $!\n");
my $status = system("perldoc -f \"$ARGV[0]\" > \"$tmpfile\"");
system("pod2man --lax --center=\"Perl Function '$ARGV[0]'\" \"$tmpfile\" | nroff -man | $pager") unless $status;
unlink($tmpfile) or die("unlink $tmpfile failed: $!\n");
rmdir($tmpdir) or die("rmdir $tmpdir failed: $!\n");
------------------------------
Date: Thu, 27 Apr 2000 10:43:51 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Any electronic perl book to share (pdf will be a bonus)
Message-Id: <39087C56.6E640B84@My-Deja.com>
> Do you have any "electronic version" that I can use. I prefer to read more than
> I source/book
parts of the text "Effective perl programming" are
kept as pdf files at www.effectiveperl.com
Click on "contents" after you go to this site.
Have fun.
==
------------------------------
Date: Thu, 27 Apr 2000 10:33:46 -0500
From: Jeff H <jeffahill@lucent.com>
Subject: Automated FTP program - anyone have one written?
Message-Id: <39085DDA.9F1CD2A9@lucent.com>
I'm a relatively new Perl programmer, and I've been asked to write an FTP
program on our Unix box that will go out to multiple win32 machines, and back-up
certain directories. It also needs to compare the date information on both
machines, and overwrite if it's more recent. This will run unattend on a chron
job, and send me e-mail if something goes wrong.
I've never used the FTP module, so I'd like some examples of what I can and
can't do before I start mapping out the program. If anyone has written any sort
of ftp program, I'd like to look at it. I would appreciate it greatly!
Jeff Hill
------------------------------
Date: Thu, 27 Apr 2000 08:54:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Automated FTP program - anyone have one written?
Message-Id: <Pine.GSO.4.10.10004270849450.21722-100000@user2.teleport.com>
On Thu, 27 Apr 2000, Jeff H wrote:
> I've never used the FTP module, so I'd like some examples of what I
> can and can't do before I start mapping out the program.
Are the docs for Net::FTP (including the libnetFAQ) somehow insufficient
for your needs? If you find something helpful that's not already in there,
be sure to contribute it!
http://www.pobox.com/~gbarr/libnet/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 27 Apr 2000 09:35:06 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: Automated FTP program - anyone have one written?
Message-Id: <39086C3A.87E4843A@NOSPAMlanois.com>
Jeff H wrote:
>
> I'm a relatively new Perl programmer, and I've been asked to write an
> FTP program on our Unix box that will go out to multiple win32
> machines, and back-up certain directories. It also needs to compare
> the date information on both machines, and overwrite if it's more
> recent. This will run unattend on a chron job, and send me e-mail
> if something goes wrong.
>
> I've never used the FTP module, so I'd like some examples of what I
> can and can't do before I start mapping out the program. If anyone
> has written any sort of ftp program, I'd like to look at it. I would
> appreciate it greatly!
>
> Jeff Hill
Take a look at the "mirror" program
http://sunsite.org.uk/packages/mirror/
You may have to add the "send me e-mail if something goes wrong"
part yourself.
All of this assumes you are running FTP servers on your win32
machines, and that the directories you want to back up are
within the view of the FTP server on each machine. If you are
not going to be running an FTP server on each machine, you will
want to consider a different approach.
--
Gerard
http://www.lanois.com/perl/
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Thu, 27 Apr 2000 10:15:50 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: changing first character of string to upper case
Message-Id: <390859A6.A16D90F2@walgreens.com>
exhacker@my-deja.com wrote:
>
> > AHEM for any guru's reading this ... why doesn't the obvious work
> > ?
> > $string =~ tr/a-z/A-Z/; # this should give you all caps ok...
>
> this does mean increment and change case...
> read the man on tr (unix)
> % man tr
>
> tr is not meant for single-character replacements in
> this context. To accomplish the task at hand, you
> must use regex (s/)
I dont think so:
perl -e '$test = "test."; print "\u$test"'
Will do the trick, or ucfirst:
perl -e '$test = "test."; print ucfirst "$test"'
There is not a need for s/// or tr/// to change
the first charachter of a string to upper case.
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $string = "this is a test.\n";
timethese (1000000, {
'ucfirst' => sub { $string = ucfirst($string) },
'escape' => sub { $string = "\u$string" },
'regex' => sub { $string =~ s/(.*)/\u$1/ }
});
__OUTPUT__
Benchmark: timing 1000000 iterations of escape, regex, ucfirst...
escape: 1 wallclock secs ( 1.65 usr + 0.00 sys = 1.65 CPU) @
606060.61/s (n=1000000)
regex: 41 wallclock secs (39.79 usr + 0.00 sys = 39.79 CPU) @
25131.94/s (n=1000000)
ucfirst: 2 wallclock secs ( 2.72 usr + 0.00 sys = 2.72 CPU) @
367647.06/s (n=1000000)
Regards,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 27 Apr 2000 16:27:11 GMT
From: "Adrian Clark" <adrian.clark@gecm.com>
Subject: Re: changing first character of string to upper case
Message-Id: <01bfb065$824c57d0$160b9482@basit47307033>
Tony,
How about:
$stringWithFirstLetterUppercase = "\u$lowercaseString";
Adrian
------------------------------
Date: Thu, 27 Apr 2000 10:46:09 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: changing first character of string to upper case
Message-Id: <390860C1.A37F228D@walgreens.com>
[ sorry if this shows up twice. ]
exhacker@my-deja.com wrote:
>
> > AHEM for any guru's reading this ... why doesn't the obvious work
> > ?
> > $string =~ tr/a-z/A-Z/; # this should give you all caps ok...
>
> this does mean increment and change case...
> read the man on tr (unix)
> % man tr
>
> tr is not meant for single-character replacements in
> this context. To accomplish the task at hand, you
> must use regex (s/)
I dont think so:
perl -e '$test = "test."; print "\u$test"'
Will do the trick, or ucfirst:
perl -e '$test = "test."; print ucfirst $test'
There is not a need for s/// or tr/// to change
the first charachter of a string to upper case.
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $string = "this is a test.\n";
timethese (1000000, {
'ucfirst' => sub { $string = ucfirst($string) },
'escape' => sub { $string = "\u$string" },
'regex' => sub { $string =~ s/(.*)/\u$1/ }
});
__OUTPUT__
Benchmark: timing 1000000 iterations of escape, regex, ucfirst...
escape: 1 wallclock secs ( 1.65 usr + 0.00 sys = 1.65 CPU) @
606060.61/s (n=1000000)
regex: 41 wallclock secs (39.79 usr + 0.00 sys = 39.79 CPU) @
25131.94/s (n=1000000)
ucfirst: 2 wallclock secs ( 2.72 usr + 0.00 sys = 2.72 CPU) @
367647.06/s (n=1000000)
Regards,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Thu, 27 Apr 2000 16:30:17 GMT
From: mchavel@kenan.com
Subject: Re: closing cursors with DBD::Oracle
Message-Id: <8e9pu2$8h1$1@nnrp1.deja.com>
Yes, I am sure it is not closing the cursor because
I am getting the error:
"ORA-01000: maximum open cursors exceeded (DBD ERROR: OCIStmtExecute)
at RTS.pm line 368."
I also checked the value of $dbh->{Kids} and it increases
after each call the the function below.
-michael
In article <3907C2DE.91DBAC1F@indra.com>,
Ron Reidy <rereidy@indra.com> wrote:
> mchavel@my-deja.com wrote:
> >
> > using the DBD::Oracle module
> > i can use $sth->bind_param_inout
> > to return a cursor from a PL/SQL procedure
> > and fetch from it.
> >
> > but how do i close the cursor?
> >
> > i am running out of open cursors fast!
> > here is my code:
> >
> > sub execute_function {
> >
> > my ($func_name, @params_in) = @_;
> > my ($params, $sth, $curh);
> >
> > for (0..$#params_in) {
> > $params .= ":in$_, ";
> > }
> > $params = substr($params, 0, -2);
> >
> > $sth = $dbh->prepare(qq{
> > BEGIN :curout := $func_name($params); END;
> > }) or warn($dbh->errstr);
> >
> > $sth->bind_param_inout(":curout", \$curh, 1,
> > { ora_type => ORA_RSET } );
> > for (0..$#params_in) {
> > $sth->bind_param(":in$_", $params_in[$_]);
> > }
> >
> > $sth->execute() or warn($dbh->errstr);
> > $sth->finish;
> >
> > DBI::dump_results($curh);
> >
> > $curh->finish;
> > }
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
> Your statement $curh->finish should close the cursor.
>
> How do you know the cursor isn't closed? Are you looking at the any
of
> the V$ views (v$open_cursor, et. al.)? Just a suggestion...
>
> --
>
> Ron Reidy
> Oracle DBA
> Reidy Consulting, L.L.C.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 27 Apr 2000 15:20:29 GMT
From: b_stark@my-deja.com
Subject: Combining strings = Win32::OLE=HASH
Message-Id: <8e9lr9$3kq$1@nnrp1.deja.com>
I know hardly anything about perl... but I need
to get a simple script to work that sends an E-
mail from data received from a form. Simple
enough... but when I combine strings together,
all I get is Win32::OLE=HASH(address) x2. Here is
a sample:
$myvar1 = $Request->Form('title');
$myvar2 = $Request->Form('from');
$result = $myvar1.$myvar2;
$Response->Write ($result);
If the name in the from field is Brad Stark and
the title is MR. I would expect to get Mr. Brad
Stark... but instead I get Win32::OLE=HASH
(0x172ab50)Win32::OLE=HASH(0x172ab8c) Anyone have
a clue what is happening?
Thanks in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 27 Apr 2000 15:08:27 GMT
From: shad sluiter <shadsluiter@my-deja.com>
Subject: data base site content
Message-Id: <8e9l4s$2kj$1@nnrp1.deja.com>
I have a web site that is getting very big. It has 700+ articles on
photography written in static HTML. Obviously this is a chore to
maintain manually.
Big content sites (CNN and most on-line magazines) have thousands of
text/photo articles obviously run on a data base. Some companies can
afford to hire custom programmers to design these data bases.
I know there must be some off-the-shelf software that is designed to
work with large quantities of text articles and serve them in a web
site. Any suggestions on name brands and cost?
Thank for your opinion,
shad
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 27 Apr 2000 08:47:26 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: data base site content
Message-Id: <Pine.GSO.4.10.10004270845230.21722-100000@user2.teleport.com>
On Thu, 27 Apr 2000, shad sluiter wrote:
> I know there must be some off-the-shelf software that is designed to
> work with large quantities of text articles and serve them in a web
> site. Any suggestions on name brands and cost?
This doesn't seem to have anything to do with Perl; off-the-shelf software
can be written in pretty-much any language. Perhaps you should search for
the newsgroups and mailing lists about websites and how to administer
them. Follow-ups set, in case there's any perl-related follow up. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 27 Apr 2000 09:19:02 -0700
From: Peter <peter_gonnissenNOpeSPAM@euroseek.com.invalid>
Subject: Re: Disk Space
Message-Id: <078c6c5a.b09998f9@usw-ex0102-084.remarq.com>
Hi Chaos,
1. I also searched newsgroup for this and could not find a
solution for my problem, so I made the following code, it's
perhaps not "Art-of-perl" but it's working.
foreach $_ (`dir c:`){s/ //g;if (/bytesfree/) {$space=$`;}}
$space contain then a value like : 165,863,424
This is based on a classic nt 4 ntfs directory layout.
Pay attention, ` is a backquote.
2. Perl come with a lot of directory function, like opendir(),
closedir(), readdir(). But I prefer to use DirHandle method,
check you documentation.
3. I think it's not possible to redirect system() and exec() to a
perl variable, but you can use the following method :
@var=`dir c:`;
Here backquotes are also used. The result of DIR C: is send to
@var.
I hope this can help you. Good luck...
In article <864n5g$sd7$1@bob.news.rcn.net>, "Chaos"
<Chaos@foo.com> wrote:
>Does anyone know how to do either of the following in Win32:
>
>1. Get the free disk space
>2. A DIR equivalent command within Perl
>3. Redirect a system call like SYSTEM("DIR") to perl without
using a tmp
>file so I can manipulate the output of the call.
>
>Thanks for the help
>
>
>
>
>
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Thu, 27 Apr 2000 09:55:50 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Eliminate duplicates from big file
Message-Id: <2865e92c.edc612cc@usw-ex0104-087.remarq.com>
Hi,
I have big file (size around 400 MB) with approximately 2.5
million lines. Each line is in particular format.
Now, I want to eliminate duplicate lines from this files..
The file is not essentially sorted. I can use Hash to store the
line and count or can store the lines in Array and apply grep
to see if they exist etc..
This has cause 'out of memory' problem on my system, which has
come from the hash size, I believe.. The program takes more than
10 minute to run also..
Is there any way I can solve this problem??
Dividing the file into different file was one solution. I don't
know how I can apply that effectively..
I appriciate your solutions or pointers.
thanks..
Samay
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Thu, 27 Apr 2000 19:17:32 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: Eliminate duplicates from big file
Message-Id: <3908762C.D43A898C@bigfoot.com>
Samay wrote:
> Hi,
> I have big file (size around 400 MB) with approximately 2.5
> million lines. Each line is in particular format.
>
> Now, I want to eliminate duplicate lines from this files..
> The file is not essentially sorted. I can use Hash to store the
> line and count or can store the lines in Array and apply grep
> to see if they exist etc..
>
> This has cause 'out of memory' problem on my system, which has
> come from the hash size, I believe.. The program takes more than
> 10 minute to run also..
You can use disk based hash
> Is there any way I can solve this problem??
>
> Dividing the file into different file was one solution. I don't
> know how I can apply that effectively..
>
> I appriciate your solutions or pointers.
You may consider converting the data from text file to
btree seen as hash by your script.
It is hard to tell which solution is the best without more information
about your program/problem.
--
Andrzej (Andrew) A. Filip http://bigfoot.com/~anfi
anfi@bigfoot.com anfi@polbox.com anfi@sdf.lonestar.org
Postings: http://deja.com/profile.xp?author=Andrzej%20Filip
------------------------------
Date: Thu, 27 Apr 2000 10:27:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Eliminate duplicates from big file
Message-Id: <Pine.GSO.4.10.10004271019160.21722-100000@user2.teleport.com>
On Thu, 27 Apr 2000, Samay wrote:
> I have big file (size around 400 MB) with approximately 2.5
> million lines. Each line is in particular format.
Each line of every possible file is in some particular format!
> Now, I want to eliminate duplicate lines from this files.. The file is
> not essentially sorted. I can use Hash to store the line and count
> This has cause 'out of memory' problem
Here's one technique you could try: Run through the file, discarding
duplicate lines in only one category at a time. For example, on the first
pass, only store in your hash (and thereby weed out) lines which start
with the three characters "abc". On the next pass, choose a different
initial string.
If you're extra clever, you could let the program choose, on each pass,
what the initial string should be. Have it use the first N-character
initial string it sees that you haven't yet scanned for. (Don't hard-code
N if you can help it.)
The larger N is, the less memory this should take for each pass. But, of
course, you'll use more memory for the hash of initial strings, and you'll
probably add a lot to the time required for the run.
Of course, if the lines all start with the same characters, you may need
to use another technique. One would be to checksum the lines (with
unpack?) and discard duplicates which have a certain checksum during each
pass. It's really the same basic technique, though.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 27 Apr 2000 18:27:47 +0100
From: nobull@mail.com
Subject: Re: Eliminate duplicates from big file
Message-Id: <u9bt2vv4h8.fsf@wcl-l.bham.ac.uk>
Samay <samay1NOsaSPAM@hotmail.com.invalid> writes:
> Now, I want to eliminate duplicate lines from this files..
> The file is not essentially sorted.
But is it essential that it be unsorted?
If not then I would just use the Unix "sort -u" that is optomised to
handle huge files efficiently.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 27 Apr 2000 12:52:24 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Eliminate duplicates from big file
Message-Id: <39087E58.639878C7@texas.net>
nobull@mail.com wrote:
>
> Samay <samay1NOsaSPAM@hotmail.com.invalid> writes:
>
> > Now, I want to eliminate duplicate lines from this files..
> > The file is not essentially sorted.
>
> But is it essential that it be unsorted?
>
> If not then I would just use the Unix "sort -u" that is optomised to
> handle huge files efficiently.
File::Sort also has a 'u' option.
- Tom
------------------------------
Date: 27 Apr 2000 17:32:21 GMT
From: Bala <engbpa@liquidinformation.com>
Subject: Fast way to do nslookup?
Message-Id: <8e9tj5$5an$1@bignews.shef.ac.uk>
Hi, can anyone tell me how I can do an nslookup in perl without exec-ing the
built-in nslookup in unix? The reason is that I'm working on a slow machine
and launching the nslookup program seem to be slowing the whole process down
so I'd like to do it natively in perl.
Thanks.
------------------------------
Date: 27 Apr 2000 12:45:14 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Fast way to do nslookup?
Message-Id: <878zxzfnf8.fsf@shleppie.uh.edu>
>> On 27 Apr 2000 17:32:21 GMT,
>> Bala <engbpa@liquidinformation.com> said:
> Hi, can anyone tell me how I can do an nslookup in perl
> without exec-ing the built-in nslookup in unix? The
> reason is that I'm working on a slow machine and
> launching the nslookup program seem to be slowing the
> whole process down so I'd like to do it natively in
> perl.
perldoc Net::DNS
http://search.cpan.org/
hth
t
------------------------------
Date: Thu, 27 Apr 2000 16:34:39 +0000
From: Dave Zempel <dave_zempel@radixtek.com>
Subject: GPIB
Message-Id: <39086C1F.1A0F2268@radixtek.com>
I'm attempting to communicate with a GPIB device (HP8594E). I've just
recently realized that my problem is in specifying the HPIB device
address. This is not /dev/gpib0. I open /dev/gpib0 and then print to
that IO channel. The problem is that since many devices can be
connected to /dev/gpib0, I also need to specify an address (718). All
of the example programs provided with the GPIB interface card come with
IO libraries that hide this addressing issue.
Has anyone done this before in PERL or any other scripting language.
And can you tell me how to handle the addressing issue?
thanks, Dave Zempel.
------------------------------
Date: Thu, 27 Apr 2000 11:15:46 -0400
From: planb@newsreaders.com (J. B. Moreno)
Subject: Hashes -- case insensitive keys?
Message-Id: <1e9qv0i.1ok1mfd1g2syn7N%planb@newsreaders.com>
Is it possible to have case insensitive hash keys without storing the
keys in either uc or lc?
I.e. some way to make $hash{'John'} and $hash{'john'} refer to the same
thing, but keys %hash return whatever was first used?
--
John B. Moreno
------------------------------
Date: Thu, 27 Apr 2000 11:21:42 -0400
From: Eryq <eryq@zeegee.com>
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <39085B06.1368CABD@zeegee.com>
"J. B. Moreno" wrote:
>
> Is it possible to have case insensitive hash keys without storing the
> keys in either uc or lc?
>
> I.e. some way to make $hash{'John'} and $hash{'john'} refer to the same
> thing, but keys %hash return whatever was first used?
You could create your own class, CaseInsensitiveHash, and then
use tie() to tie a hash to it. I think you want the "perltie"
manual page.
HTH,
Eryq
------------------------------
Date: Thu, 27 Apr 2000 14:04:50 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <Pine.A41.4.10.10004271352290.14050-100000@ginger.libs.uga.edu>
On Thu, 27 Apr 2000, J. B. Moreno wrote:
> Is it possible to have case insensitive hash keys without storing the
> keys in either uc or lc?
>
> I.e. some way to make $hash{'John'} and $hash{'john'} refer to the same
> thing, but keys %hash return whatever was first used?
>
> --
> John B. Moreno
The short answer is, "No."
If you don't mind my asking, why don't you want to use uc or lc? Is it
because you want to keep the original case?
If so, you might try an aggregate structure
my %hash = (
john => [ 'John', "John's data" ],
mary => [ 'Mary', "Mary's data" ],
);
In this case, $hash{john}[0] contains the name in it's original case,
and $hash{john}[1] contains the data you want. You could hide this by
making the hash an object and possibly implementing a tie.
By the way, "keys %hash" returns something, but it's not "whatever was
first used", unless I'm mistaken.
--
Brad
------------------------------
Date: Thu, 27 Apr 2000 08:24:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: help with a request
Message-Id: <MPG.1371fba71ab9164798a996@nntp.hpl.hp.com>
In article <8e9e4g$qb3$1@nnrp1.deja.com> on Thu, 27 Apr 2000 13:08:43
GMT, exhacker@my-deja.com <exhacker@my-deja.com> says...
...
> I would also recommend using strict on this one, to avoid having your
> database interact with itself if two people are using it (or do i
> misunderstand the function of strict....)
You misunderstand completely. Maybe you are thinking of file locking.
perldoc strict
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 27 Apr 2000 08:31:40 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Hiding Password
Message-Id: <Pine.GSO.4.10.10004270831080.21722-100000@user2.teleport.com>
On Thu, 27 Apr 2000, Gary wrote:
> How can I get perl to hide password (i.e. not echo to screen)as the
> user types their password in.
Have you seen the FAQ?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 27 Apr 2000 11:49:06 -0500
From: "Paul R. Andersen" <andersen+@rchland.ibm.com>
Subject: Re: how to close a subrutine
Message-Id: <39086F81.4288E5AB@rchland.ibm.com>
Use the debugger? Or, are you looking for something else?
Saddek Rehal wrote:
> How can I run make my script to stop after each subroutine.
>
> &step1 && &step2 && &step3 && &step4;
>
> thank you for helping
>
> --
> Saddek Rehal
> Chalmers tekniska högskola,
> Arkitektur, Byggnadskonst
> 412 96 Göteborg
> Tel: 031-772 24 75
--
Paul Andersen
-- I can please only ONE person per day.
-- Today is NOT your day.
-- Tomorrow isn't looking good either.
------------------------------
Date: 27 Apr 2000 11:59:43 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: how to close a subrutine
Message-Id: <87bt2vfpj4.fsf@shleppie.uh.edu>
>> On Thu, 27 Apr 2000 16:26:36 +0200,
>> Saddek Rehal <saddek@arch.chalmers.se> said:
> How can I run make my script to stop after each
> subroutine.
In the subject you want to "close" a subroutine, but here
you want to "stop" one.
> &step1 && &step2 && &step3 && &step4;
I'm not sure what you're trying to do. Do you want the
program to stop == exit after each step? No, that would
be silly. Do you want the program to pause == stop after
each step until some event occurs before going on to the
next step? (e.g. timeout or keyboard input)
Remember, noone else in this group has any idea of the
context you're operating in, or what assumptions you're
making.
> --------------5039406595B449F0205EAF91 Content-Type:
> text/x-vcard; charset=us-ascii; name="saddek.vcf"
> ...
> --------------5039406595B449F0205EAF91--
Please don't post this kind of stuff into USENET. It just
gets in the way and increases article size.
------------------------------
Date: Thu, 27 Apr 2000 12:02:53 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: how to close a subrutine
Message-Id: <390872BD.4DFB0CB3@walgreens.com>
Saddek Rehal wrote:
>
> How can I run make my script to stop after each subroutine.
>
> &step1 && &step2 && &step3 && &step4;
I am assuming that you want to execute the next sub in
your chain only if the previous sub returns a true value,
right?
#!/usr/bin/perl -w
use strict;
&test(1) && &test(1) && &test(0) && &test(1);
sub test { $_[0] ? print "$_[0]\n" : return 0 }
__OUTPUT__
1
1
As you can see the second third call to
&test was made, but returned false (0)
so the fourth call was never made at all.
Now, if my assumption is wrong, and you
indeed want it to stop after each call,
then:
perldoc -f sleep
should give you what you need.
hth.
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Thu, 27 Apr 2000 12:11:10 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: how to close a subrutine
Message-Id: <390874AE.457419D5@walgreens.com>
"Andrew N. McGuire" wrote:
[ snip ]
> As you can see the second third call to
> &test was made, but returned false (0)
> so the fourth call was never made at all.
s/ second / /;
Sorry :-(
[ snip ]
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2879
**************************************