[8275] in Perl-Users-Digest
Perl-Users Digest, Issue: 1892 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 13 17:07:27 1998
Date: Fri, 13 Feb 98 14:00:28 -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 Fri, 13 Feb 1998 Volume: 8 Number: 1892
Today's topics:
Re: - BEAUTIFUL BLONDE!! --(picturepost)blo0045.jpg[1/ <ray@icix.net>
An aside.. (StarScream)
Re: Building Perl on Solaris - I am *not* using GNU ls (Victor Brilon)
Can Comm.pl handle arrows key (Yongyan Wang)
Creating Arrays from a file of names <rondtree@cadence.com>
Re: Creating Arrays from a file of names <SNIPhsommer@micro.ti.comSNIP>
Decryptable crypt? <mikihasa@worldnet.att.net>
Re: FAQless Forays (was: Code Example Needed) (Gabor)
Re: FAQless Forays (was: Code Example Needed) (Gabor)
Re: FAQless Forgays (Gabor)
Re: FTP as filehandle (Reilly Shea)
Re: Help!! pattern matching <cantrela@agcs.com>
Re: htpasswd <mikihasa@worldnet.att.net>
Passing values into a subroutine from an array... <vidyanan@pilot.msu.edu>
Question re: CGI Process Mgmt. <nslater@ms.com>
Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ (Gabor)
Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ <dboorstein@shopcfn.com>
Re: retrieving html files (Hunter Johnson)
Re: RFC about "Matt's Script Archive" <*@qz.to>
Stupid problem that got me stumped <achoy@us.oracle.com>
RE: Using list as value of hash <barnett@houston.Geco-Prakla.slb.com>
Re: Using list as value of hash <cmargoli@world.northgrum.com>
Re: what does "deprecate" mean? (Gabor)
Re: Why is Tom Christiansen so rude? (Billy Chambless)
Re: Why is Tom Christiansen so rude? <*@qz.to>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 13 Feb 1998 15:33:45 -0500
From: Ramon Castillo <ray@icix.net>
Subject: Re: - BEAUTIFUL BLONDE!! --(picturepost)blo0045.jpg[1/1]
Message-Id: <34E4AE29.687E@icix.net>
gbqoonqj@BeauBlonde.com wrote:
>
> ---------------------------------------------------------------
>
> http://204.238.155.37/biz/PREMIUM/enter.html
> http://204.238.155.37/biz/PREMIUM/enter.html
>
> http://204.238.155.37/biz/PREMIUM/enter.html
> http://204.238.155.37/biz/PREMIUM/enter.html
NOOOO please this is a perl group where I just want to talk about it
when I want something else I now where to find it :-) Don't you...
RC
--
#!/usr/local/bin/perl
use Heart::WithBrain;
while ($god->bless == $Internet && $Perl == $Cool){
$Be = "Happy";
$Live = "Love";
$Hack = "Fun";
} # RC ray@icix.net
------------------------------
Date: 13 Feb 1998 14:58:48 -0500
From: hallm4@cortez.sss.rpi.edu (StarScream)
Subject: An aside..
Message-Id: <6c28lo$7lje@cortez.sss.rpi.edu>
> /(foo) (bar)/ = ("xyzzy", "plugh")
I've always felt it a shame that most people younger
than me will never get/understand these references. :-)
--
<HTML><META HTTP-EQUIV="Refresh"
CONTENT="8;URL=http://www.wankers.com"><BODY bgcolor="red"
text="black"><BLINK><STRONG><FONT SIZE=+7> <P>HTML is *BAD* in
Usenet!<P>Turn it off now!<P></STRONG></BLINK></BODY></HTML>
------------------------------
Date: Fri, 13 Feb 1998 13:55:32 -0600
From: victor@vail.net (Victor Brilon)
Subject: Re: Building Perl on Solaris - I am *not* using GNU ls and as!!!!
Message-Id: <victor-1302981355330001@192.168.10.1>
I'm assuming that /usr/ccs/bin is in your PATH as well? Post (or email
me) with what Solaris version you're running and the output of 'env' and
I'd be glad to help.
Good luck,
Victor
In article <34E482D3.CC0EBD4D@ixlabs.com>, chris@ixlabs.com wrote:
>I'm building Perl 5.004_03 on a Sparc Solaris box - having lots of
>trouble though....
>
>gcc 2.7.2 is in /usr/local/bin/gcc
>as, ld are in /usr/ccs/bin
>
>All of these binaries are found in these location first in my PATH as
>confirmed by which(1).
>
>I've compiled a "hello, world" with gcc so I know that at least pretends
>to work...
>
>But Configure keeps complaining that I am not using /usr/ccs/as & ld,
>and that these are the GNU versions which won't work....
>
>I know these aren't the GNU versions because they don't accept --version
>as a command line parm (as the GNU versions on my Linux box do).
>
>And if I ignore this warning, Configure will give me a whoa! and tell me
>my compiler isn't working...
>
>What am I doing wrong? I've never had this much trouble building on
>Sparc Solaris.
>
>-Chris
>
>PS I tried patchlvel 04 as well.
--
It's easier to fix Unix than live with NT
------------------------------
Date: 13 Feb 1998 19:27:44 GMT
From: ywang@news (Yongyan Wang)
Subject: Can Comm.pl handle arrows key
Message-Id: <6c26rg$q54@myst.plaza.ds.adp.com>
How can I send a "arrow key" char to the remote job, which
is initialized using Comm.pl.
E.g.
If I want to send a "OK", I can print $proc_handle "OK\n";
If I want to send a "<-" key, how should I do?
Thanks,
--
Yongyan Wang
Automatic Data Processing (ADP) | Email: ywang@plaza.ds.adp.com
ADP Plasa |
2525 SW First Avenue |
Portland, OR 97201 USA | Office (503) 402-3882
------------------------------
Date: Fri, 13 Feb 1998 14:46:15 -0500
From: Joseph Roundtree <rondtree@cadence.com>
Subject: Creating Arrays from a file of names
Message-Id: <34E4A307.53EF41CD@cadence.com>
Hello,
I have a file containing machine names. The file can be put into either
of two forms; one form has
the names each to a line, all 1100 of them; the other form has the names
occupying one long line
with the names separated by spaces. I need to know how do I produced a
file with lines containing
10 hostnames per row with the names separated by spaces.
In pictures:
from this: x or this: x x x x x x x x x x x x
x x x x x x x x x x x x x x x x x x x x x x
x
x
x
to this: x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
Thank You,
J. Roundtree
------------------------------
Date: Fri, 13 Feb 1998 14:35:05 -0600
From: Holly Sommer <SNIPhsommer@micro.ti.comSNIP>
Subject: Re: Creating Arrays from a file of names
Message-Id: <34E4AE79.D768F2DA@micro.ti.comSNIP>
Either way, once you get your hostnames into @hosts, just do this:
$i = 0;
foreach $host (@hosts) {
if ( $i < 10 ) {
print STDOUT "$host ";
$i++;
} else {
print STDOUT "$host\n";
$i = 0;
}
}
Pretty basic programming situation.
-Holly
------------------------------
Date: Fri, 13 Feb 1998 15:10:35 -0500
From: "Michael R. Harper" <mikihasa@worldnet.att.net>
Subject: Decryptable crypt?
Message-Id: <6c28vv$g2v@bgtnsc02.worldnet.att.net>
Newbie question:
The Unix man page says that crypt is a one-way street. I am looking for
an encryption command for which there is an inverse operation
(decrypt?). The Camel book suggested the possibility of using a PGP
module.
I was only able to find one post to this group that mentioned PGP. Can
someone steer this newbie in the right direction? I currently only need
the ability to encrypt and decrypt data, so I guess I do not need
anything fancy.
Sincerely,
Michael R. Harper
mikihasa@worldnet.att.net
------------------------------
Date: 13 Feb 1998 20:49:32 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <slrn6e9car.c0i.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Eli the Bearded <*@qz.to> wrote :
# > Try modifying your From: address next time you post.
#
# Yup, I did that a few months ago and noticed (and reported) a cosmetic
# bug in the RTFM autoreplier. Then I changed twice more and I am happy
# to say that the bug has been fixed.
#
# It still doesn't help for those who munge their address though.
And most people do, unfortunately. And then have the nerve to ask for
a copy of your reply Cc:'d to them!
------------------------------
Date: 13 Feb 1998 20:51:45 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <slrn6e9cf0.c0i.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Douglas Wilson <dgwilson@gte.net> wrote :
# Frank@but_dont_use_this.address wrote:
# > (I try to concatenate all lines in a file to a string)
#
# > $data ="";
# > open MULT_HANDLE, "<$file" || die "ERROR: can't read $!";
# > @files = <MULT_HANDLE>;
# > close (MULT_HANDLE);
# > foreach $aLine (@files) {
# > $data .= $aLine;
# > }
#
# The foreach loop could be replaced with:
# $data=join "",@files;
Or for that matter you could've done it even more simply and without
needing double the memory
local ($/) = undef;
gabor.
--
What about WRITING it first and rationalizing it afterwords? :-)
-- Larry Wall in <8162@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 13 Feb 1998 20:45:17 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: FAQless Forgays
Message-Id: <slrn6e9c2s.c0i.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Chip Salzenberg <chip@mail.atlantic.net> wrote :
# According to Russ Allbery <rra@stanford.edu>:
# >I think people who use Usenet had better start getting used to the idea
# >that good posters are not necessarily a renewable resource ...
#
# Where is Linus Torvalds? Where is Larry Wall? They're gone, because
# Usenet is too much of a time waster. I'm seldom here (though when I'm
# here people notice :-)), for the same reason.
#
# A moderated newsgroup, I would read regularly. Even Larry might.
I agree. There is far too many posts now on c.l.p.m. It's nearly
impossible to read them all, and the good posts get drowned out by the
bad ones. :-(
------------------------------
Date: Fri, 13 Feb 1998 20:59:56 GMT
From: traveler@rust.net (Reilly Shea)
Subject: Re: FTP as filehandle
Message-Id: <34e4b108.24097521@news.rust.net>
On Thu, 12 Feb 1998 20:37:39 GMT, traveler@rust.net (Reilly Shea)
wrote:
>I've been pulling my hair out on this one, reading pg 191-194 of the Camel
Blah, Blah, Blah
Thanks to all of you for your help. I was a little reluctant to post
here. The last time I posted to a comp.lang group (it was moderated, I
won't say which one) my post was rejected as "trivial". Easy to say,
but it was 2:00 in the morning and I'd been hammering my head against
the wall for about 4 hours. Heavy sigh, I can let go of that
resentment now.
After reading the replies I ran out and got the O'Reilly Perl
Resource Kit, which I've been waiting for an excuse to buy.
I was delighted when I flipped to the page on Net::FTP and saw that
the module was written by Graham Barr, who replied first to my post.
Very modest of you not to mention that in your reply Graham. I feel
like I've had some sort of internet brush with fame here.
Anyway thanks again to all of you.
Reilly Shea
Detroit, MI (a.k.a. The Motor City)
------------------------------
Date: Wed, 11 Feb 1998 11:22:22 -0700
From: Andy Cantrell <cantrela@agcs.com>
Subject: Re: Help!! pattern matching
Message-Id: <34E1EC5D.1D217793@agcs.com>
Hans Van Lint wrote:
>
> Sorry to bother you again, but I wanted to explain something:
> I have a form where you are able to fill in or don't fill in 8 fields.
> When ready, you submit the form.
>
> In my program I read lines from a text file, and then I look if the fields
> filled in, exist in the resp. fields of the database.
> I want it to look for field AND field AND ...
> So, that's why I write $count++, and when, after checking the 8 fields,
> $count = 8, I can show the record.
>
> My code looks like this:
**NOTE:
**Original code segment removed. Revised edition replaced
**Intent was to give a version that was easier to read, not
**an edition that was the most efficient.
$count =0;
#this is field 1 (if input in field then add 1 to count)
if (($fnaambedrijf =~ /$input{'ubedrijf'}/i) ||
($fomschrbedrijf =~ /$input{'ubedrijf'}/i)) { ++$count ;};
#field 2 (if input in field then add 1 to count)
if ($fselbureau =~ /$input{'usbureau'}/i) { $count++ ;};
#field 3 (if input in field then add 1 to count)
if (($ffunctie =~ /$input{'ufunctie'}/i) ||
($fbaseline =~ /$input{'ufunctie'}/i) ||
($fomschrfunctie =~ /$input{'ufunctie'}/i)) { ++$count ;};
#field 4 (if input in field then add 1 to count)
if ($fprofiel =~ /$input{'uprofiel'}/i) { $count++;};
#field 5 (if input in field then add 1 to count)
if ($faanbod =~ /$input{'uaanbod'}/i) { $count++;};
#field 6 (if input in field then add 1 to count)
if ($finteresse =~ /$input{'uinteresse'}/i) { $count++;};
if ($input{'upcvan'} eq '') {
#field 7 (if input in field then add 1 to count)
$count++;
} elsif ($input{'upcvan'} < $fpostgem) {
$count++;
};
if ($input{'upctot'} eq '') {
#field 8 (if input in field then add 1 to count)
$count++;
} elsif ($input{'upctot'} >= $fpostgem){
$count++ ;
};
if ($count == 8){ $tonenfunctie = 1;} #if $count = 8 then show line
> Well, I tried everything already, and it just doesn't work.
Well, almost.
>
> Am I correct in thinking when a field is blank it automatically increases
> $count?
Depends on how all the vars are set up. Be careful on the difference
between 'blank' and 'null' (that is, defined but with a value of '')
I'm going to guess that white space in your vars is at the bottom of
this.
Suggestions:
Pass all your input parameters through a s/^\s*//; s/\s*$//; type
filter to make sure that anything with white space is removed.
Verify the values in %input are indeed what you think they are.
E.G. for each $key (keys(%input)) { print "key >$key< val
>$input{$key}<\n" ;};
For debugging variable values, I often put delimiters around the
output
so that white space becomes obvious. ><'s used here.
Could toss in another comment or two, but I'd either be way off base
from the intent of your program or falling into additional personal
programming habits.
OTHER: News group note - I've been informed that previous postings by
myself have had HTML mixed in. I'm working on removing this so that
a wider variety of browsers can review this (should one care to do so)
If what I've altered doesn't correct this, please let me know. (i.e
Did I let HTML get into this posting?)
--
Andy Cantrell
AG Communication Systems
E-Mail: cantrela@agcs.com
Ph. (602)582-7495 Rm. X18
------------------------------
Date: Fri, 13 Feb 1998 15:18:41 -0500
From: "Michael R. Harper" <mikihasa@worldnet.att.net>
To: Luc Van Linden <Luc.VanLinden@esat.kuleuven.ac.be>
Subject: Re: htpasswd
Message-Id: <6c29f6$g2v@bgtnsc02.worldnet.att.net>
Luc Van Linden wrote:
> Hello,
>
> The command "htpasswd" doesn't seem to work in my "perl"-scripts.
<snip>
You can always create your own htpasswd file using uuencode or crypt,
right? I believe the basic protection scheme just uses the username, a
colon, and the uuencoded password entered on the htpasswd command line
to create the entries in the .htpasswd file. If that does not spark any
creativity within you, please read on...
Here is a post from a Unix newsgroup that may be relevant to your
problem:
Thanks for all of your help. Here is my solution, which I gleaned from
everyone's input:
A Perl script:
#!/usr/bin/perl5
for($i = 0;$i < $ARGV[1];$i++) {
`test.exp $ARGV[0] $i $ARGV[2]`
}
exit 0;
drives the expect script below:
#!/usr/contrib/bin/expect -f
set pw_dir "[lrange $argv 0 0]"
set user_number "[lrange $argv 1 1]"
set user_name "[lrange $argv 2 2]"
spawn htpasswd -c $pw_dir/.htpasswd $user_name$user_number
expect {
"New password:" {
send "$user_name$user_number\r"
exp_continue
}
"Re-type new password:" {
send "$user_name$user_number\r"
}
}
expect eof
I wasn't sure if there was a more concise was to access the $argv
variable
from expect, so I went brute force. This essentially allows me to setup
an
arbitrary number of usernames with passwords. Granted, having matching
username and password is not the best security practice, but it sure
beats
running htpasswd 1000 times manually. Besides, that is just for my
application.
Thanks Again,
Michael R. Harper
Michael R. Harper wrote:
> Why can't use a "here" document to input the password information to
the
> htpasswd command? For instance:
>
> htpasswd -c passfile mike <<eof
> x3e2
> x3e2
> eof
>
> When I try the above, I just get prompted to enter the password. Why
> doesn't it use the input in the here document? Is it a security
thing?
> Is there some way around it?
>
> Michael R. Harper
> mikihasa@worldnet.att.net
------------------------------
Date: Fri, 13 Feb 1998 15:23:40 -0500
From: Premgith Vidyanandan <vidyanan@pilot.msu.edu>
Subject: Passing values into a subroutine from an array...
Message-Id: <Pine.GSO.3.96.980213151139.832A-100000@arctic.cps.msu.edu>
I call this subroutine in the following manner,
@val[0] = &result(@array[0]);
sub result{
$value = grep "who" @array[$i];
return $value;
}
This does not work because $i is not defined. if I assingn a value of $i
with 0 then it works but it does not work when I call the same function
and change the value of $i.
The question I have is how can I pass the values from the call to the
subroutine for different values of the array, for instance how can I call
the same subroutine with @array[1];@array[2] .... and so on and make it
return different values.
. Is there a better way to do this....
In c you can just declare the arguments in the beginning and then just
pass the values in to the function, I need the equivalent of the same
process in perl...
Thanks...
Premgith Vidyanandan
Tel -: Res (517) 333-4201
Off (517) 355-4500 ext(193)
E-mail - vidyanan@pilot.msu.edu
------------------------------
Date: Fri, 13 Feb 1998 13:01:23 -0800
From: Nathaniel Slater <nslater@ms.com>
Subject: Question re: CGI Process Mgmt.
Message-Id: <34E4B4A3.E0C3D2C1@ms.com>
I have noticed that CGI scripts with dangerous or unstable code will
often hang on the server long after the browser has executed these
commands. Recently I have been experimenting with wrappers for these
scripts. Basically, if you fork the CGI executable and then handle the
child process effectively, it is possible to have the parent kill a
rogue child process.
However, I have yet to find a fool-proof method; some types of bad code,
like infinite loops, have been immune to the methods I've used. What is
the most effective way to use fork(), and SIGCHLD to terminate a CGI
executable that has gone awry?
--
Nate Slater
West Coast PCS Unix Support
San Francisco, CA
------------------------------
Date: 13 Feb 1998 20:41:27 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <slrn6e9brl.c0i.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Fritz Knack <fritz.knack@nospam.POPULUS.net> wrote :
# For a report I've written, I'm trying to determine if a given phone
# number is an 800-class number, i.e., it begins with 800 or 888.
#
# Anyway, below are two snippets of code. The first one is what works
# the way I want it to. The second pulls too much, e.g., area code 813
# (Houston? Dallas?) "counts" as an 800-class number.
Neither of what you're doing works.
[800|888] matches an 8 or a 0 or a |
8[0{2}|8{2}] matches 8 followed by 0 or { or 2 or } or | or 8
What you want is
/^8(00|88)/
# Can anyone tell me what's going on? I would have though the two were
# classic TMTOWTDI. (If it matters: perl 5.0003_07, Win32 build 311.)
Nope it doesn't matter.
gabor.
--
It is, of course, written in Perl. Translation to C is left as an
exercise for the reader. :-)
-- Larry Wall in <7448@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Fri, 13 Feb 1998 16:43:30 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <34E4BE82.970E23A5@shopcfn.com>
Alan Schwartz wrote:
> I got curious, reading this, about whether there was a difference
> in performance between (800|888), 8(00|88), and 8[08]{2}, along with
> versions using (?: instead of (.
[snip]
>
> (2) ^8[08]{2} is slightly faster than ^8(?:00|88). I think one of the
> ORA Perl books (camel?) mentions that alternation is relatively
> slow, but both seemed to do pretty well here. This is probably a
> tribute to the pattern-match compiler, which may again have compiled
> them to very similar patterns.
be careful here. it may be faster, but it has a problem. it will
also match '808' and '880' which are not desirable. the {2} says
exactly 2 of either of these character (0 or 8), but they don't
have to be the same. i don't know how this would fit in the
benchmark scheme but /^8([08])\1/ should also work. though i
tend to prefer the clarity of your first and second suggestions.
cheers,
--
dan boorstein <dboorstein@shopcfn.com>
------------------------------
Date: 13 Feb 1998 21:46:38 GMT
From: jhunterj@lexis-nexis.com (Hunter Johnson)
Subject: Re: retrieving html files
Message-Id: <6c2evu$pul@mailgate.lexis-nexis.com>
In article <34E44275.11CD@netjob.dk>, Ernst <e.christensen@netjob.dk> wrote:
> I think this is a simple question: How do I get a file from a remote
> webserver, without using the LWP module (I am not allowed to install
> this module on our server).
You can get the text of a non-frame page by making a system call to
lynx and using the -dump switch. There are probably switches that'll
let you capture the html as well.
Hunter
--
J. Hunter Johnson | "A little consistent wholesome modeling and
jhunterj@lexis-nexis.com | costly servanthood are worth millions of
(937) 865-6800 x5385 | true words harshly spoken."
Lexis-Nexis, Dayton, OH | -- Ron Sider
------------------------------
Date: 13 Feb 1998 20:02:33 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <qz$9802131439@qz.little-neck.ny.us>
Mark Kramer <c28f62@world.std.com> wrote:
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
> > c28f62@world.std.com (Mark Kramer) writes:
> >> Can anyone reading this thread, where Matt has been referred to as
> >> either evil or bad, wonder why people don't jump up and down with glee
> >> at the thought of giving their code to this group?
> >Lots of people have donated well written code to the perl community.
...
> Admit it; if it was someone besides Tom who was complaining that a free
> piece of software wasn't written the way he liked code to be written,
> would you you be supporting him or telling him to write his own if he
> didn't like the free stuff?
Hell I've complained about free perl code that was written terribly,
and my typical solution has been to patch or rewrite it and release
my version. Most recently I set up swish-e for a web site I run. The
CGI program that came with it was terrible. Cheap homebrew CGI parsing,
no -w (and four warnings when added), no "use strict", no -T (and many
tainting problems), etc. So I completely rewrote it adding new features
like selectable databases, placing the form onto the output page for
easier refinement of searches, and generation of a new blank form when
called without formdata. I then put it on an FTP site and posted the
URL to the swish-e mailing list. (<URL:ftp://qz.to/pub/search.cgi>)
One of the reasons I am using swish-e actually is because another free
piece of indexing software I looked at was so bad that I cut my losses
with it and looked around for something better.
Elijah
------
has only written one CGI program
------------------------------
Date: Fri, 13 Feb 1998 11:54:22 -0800
From: Allen Choy <achoy@us.oracle.com>
Subject: Stupid problem that got me stumped
Message-Id: <34E4A4EE.D2855E28@us.oracle.com>
Okay. The require function can include modules dynamically by doing a
require MODULE;
Since I don't know which module I'm requiring ahead of time, I need to
pass in a variable to
the require. But the variable is a string, and I get a runtime error on
the require line.
Anyone know how I can get around this?
I'm running 5.004_04 on solaris.
Thanks--Allen
------------------------------
Date: Fri, 13 Feb 1998 13:32:38 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: RE: Using list as value of hash
Message-Id: <34E49FD6.7C606D6B@houston.Geco-Prakla.slb.com>
Ed Avis wrote:
>
> My program reads in a list of "IDs" and associated "names". Each "ID"
> has zero or more "names" associated with it. For example
>
> NAME ID
>
> apple 2
> pear 2
> goat 3
> bear 4
> banana 2
>
<snip>
How about this:
#!/usr/local/bin/perl -w
#
open (IF, "filename");
while (<IF>)
{
if (/^$/) { next; }
#
# checks for and ignores blank lines.
@words = split;
if (scalar(@words) < 2 or $words[0] =~ /^$/ or $words[1] =~ /^$/) {
# Checks for invalid entries in filename and skips them
print "Invalid data entered.\n";
next;
}
$id = $words[1];
#
# sets id, as your code did.
if (defined($names{$id}) and $names{$id}) {
#
# if already defined, append data to end of current data
# tab seperated data, at that.
#
$names{$id} = $names{$id} . "\t" . $words[0];
} else {
#
# Otherwise, set the hash{key} to contents of id
$names{$id} = $words[0];
}
}
foreach $key (keys %names) {
print "$key: $names{$key}\n";
}
__END__
filename contents:
apple 2
pear 2
goat 3
bear 4
banana 2
dog 3
. 3
4
<EOF>
------
Prints out:
Invalid data entered.
2: apple pear banana
3: goat dog .
4: bear
HTH.
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: Fri, 13 Feb 1998 20:21:55 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Using list as value of hash
Message-Id: <34E4AB63.1F51@world.northgrum.com>
Ed Avis wrote:
> What I'd like to do is something like this:
>
> while (<IF>)
> {
> @words = split;
> $id = $words[1];
> @names{$id} = (@names{$id}, $words[0]); #!
> }
>
> where the hash stores a list of names that correspond to each ID.
> Later on, I need to look up an ID in the hash and find the list of
> names it maps to.
>
Please look at the man pages perlref, perldsc and perllol. There
you will find out about references and lists of lists. These are
fairly advanced topics, but they will allow you to create arbitrarily
complex data structures.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 13 Feb 1998 20:34:36 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: what does "deprecate" mean?
Message-Id: <slrn6e9beq.c0i.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Kevin B Cohen <kcohen@julius.ling.ohio-state.edu> wrote :
# okay, i *know* what it means to "deprecate" in english, but what does
# it mean in perlish? here are some examples of usage (hope i'm not
# violating any laws of copyright...):
#
# "This usage is vaguely deprecated, and may be removed in some future
# version of Perl." (camel, 2nd ed., pg. 72)
#
# "Use of $* is now deprecated, and is allowed only for maintaining
# backwards compatibility with older versions of Perl." (camel, 2nd
# ed., pg. 129)
#
#
# I can imagine deprecating a novel or a usage in English, but I'm
# having trouble imagining deprecating a variable....
deprecated means disapproved of. so usage of $* is disapproved of
since it might disappear in future versions of Perl.
gabor.
--
This made me wonder, suddenly: can telnet be written in perl?
Of course it can be written in Perl. Now if you'd said nroff,
that would be more challenging...
-- Larry Wall
------------------------------
Date: 13 Feb 1998 21:31:50 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Why is Tom Christiansen so rude?
Message-Id: <6c2e46$i9j$1@nntp.msstate.edu>
In article <m2oh0cbwuq.fsf@ono.tc.net>, Douglas McNaught <doug@tc.net> writes:
|> Todd Hoff <tmh@possibility.com> writes:
|> > Those of us who have worked in the service industry recognize it
|> > as a condition known as "contempt for the customer."
|> I wasn't aware that we on the newsgroup are Tom's customers.
Yeah, TC's so rude and surly that I may just take my stoopid questions
elsewhere!
------------------------------
Date: 13 Feb 1998 21:46:18 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Why is Tom Christiansen so rude?
Message-Id: <qz$9802131627@qz.little-neck.ny.us>
Todd Hoff <tmh@possibility.com> wrote:
> Douglas McNaught wrote:
> > So you're saying we are his customers. I disagree.
> You are so missing the point. It's a metaphor. For whatever reason tom takes
> it on himself to answer *a lot* of questions from a lot of people. When
> people deal with other people for long periods of time under less than ideal
^^^^^
> social conditions it is not uncommon for such people to begin to feel
^^^^^^^^^^^^^^^^^
> "contempt for their customer." It happens with cops, it happens with wait
> persons, it happens with tech support, it happens in sales, it happens.
I think this is not applicable because Tom's complaints are really about
the social conditions (people expecting everything for nothing and could
you please demunge the address before mailing the reply since reading the
newsgroup would be too much work).
There do exist newsgroups which lack this social condition and Tom would
like to see c.l.p.m become one again.
He would like to see September 1993 end.
> RTFM
If you are going to say that about something offtopic for the group,
you really should provide references.
Elijah
------
followups set
------------------------------
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 1892
**************************************