[12481] in Perl-Users-Digest
Perl-Users Digest, Issue: 6081 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 21 18:07:27 1999
Date: Mon, 21 Jun 99 15:00:23 -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 Mon, 21 Jun 1999 Volume: 8 Number: 6081
Today's topics:
Re: A buggy intersection-method <d-edwards@uchicago.edu>
Re: A buggy intersection-method (Greg Bacon)
Re: a thread on threads <gellyfish@gellyfish.com>
Re: Cure for document deficiency <webmaster@chatbase.com>
Database Manipulation paulm@dirigo.com
Re: Docs for cmdline switches - where? <cassell@mail.cor.epa.gov>
Embedding problem w/ perl_parse() <dwbrock@veribest.com>
Re: Good reasons for avoiding modules (was: Re: Afraid (Paul David Fardy)
Having an external script modify %ENV? (Andrew Khazanov)
Re: Having an external script modify %ENV? (Greg Bacon)
Help with timing out an operation....(My broken code in (Mitch)
Re: How do I delete lines from a file (Andrew Johnson)
Re: Interpreting MS-ASCII - anyone have a filter? <flavell@mail.cern.ch>
Re: Interpreting MS-ASCII - anyone have a filter? <gellyfish@gellyfish.com>
Re: Interpreting MS-ASCII - anyone have a filter? (Bart Lateur)
Modem control in perl? ()
Re: multidimensional arrays with functions push and pop <d-edwards@uchicago.edu>
Need Perl Help? (programming/modify script/install scri mark@bstar.net
ODBC and CGI dotero@photocircuits.com
Re: ODBC and CGI <rg@fubar.net>
Re: perl help (Jon Bell)
Please Help with Perl 5 <luka@islandnet.com>
Re: Problem with DB_File (Benjamin Franz)
Re: Question about TTY's... (Mitch)
Return value in script. <xyf@inetnebr.com>
Re: Search script performance <ehpoole@ingress.com>
sorting on 2 fields <exujep@exu.ericsson.se>
Re: Statistics for comp.lang.perl.misc (Bart Lateur)
Re: Statistics for comp.lang.perl.misc (Greg Bacon)
system call <technology@workmail.com>
Re: To obfuscate or not? (Larry Rosler)
Re: Trying again... (Mitch)
Re: virtualave.net <webmaster@chatbase.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Jun 1999 21:06:09 GMT
From: Darrin Edwards <d-edwards@uchicago.edu>
Subject: Re: A buggy intersection-method
Message-Id: <tgvhchw9fi.fsf@noise.bsd.uchicago.edu>
rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
>
> Darrin Edwards <d-edwards@uchicago.edu> wrote:
>
> > @lol = map {defined($_) ? [getEntries(lc $_)] : undef} @ARGV;
> >
> But that's overkill, because how would @ARGV get undefined values
> anyway? It's very hard to pass undef in from the command line...
D'oh. Perl is so good at helping me think more _generall_ about
problems, now I am running into the opposite problem of missing
specifics. :(
Darrin
------------------------------
Date: 21 Jun 1999 21:24:41 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: A buggy intersection-method
Message-Id: <7kmaip$iht$2@info2.uah.edu>
In article <1dtpvth.12vqbdzjqzudqN@p7.tc8.metro.ma.tiac.com>,
rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
: But that's overkill, because how would @ARGV get undefined values
: anyway? It's very hard to pass undef in from the command line...
It can be useful to lie to yourself about the contents of @ARGV.
local @ARGV = ( '/some/file', 'ps auxww |' );
while (<>) { ... }
Greg
--
The earth has become small, and on it hops the last man, who makes
everything small. His species is ineradicable as the flea; the last
man lives longest.
-- Nietzsche
------------------------------
Date: 21 Jun 1999 20:28:01 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: a thread on threads
Message-Id: <7km78h$7ct$1@gellyfish.btinternet.com>
On Mon, 21 Jun 1999 10:08:17 -0400 Greg Bartels wrote:
> Kai Henningsen wrote:
>>
>> Hmm, thinking about this ... how much setup would a Perl coroutine
>> actually need? Sounds like it should be doable from an xs.
>
> ya lost me there. what is xs? could you write this functionality into
> perl?
>
XS is the mechanism by which extensions can be written in C and
(generally) loaded dynamically - you might want to have a look at the
perlxstut manpage to see if that kind of this is for you ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 21 Jun 1999 15:07:37 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
To: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Cure for document deficiency
Message-Id: <376EB7A9.5DB76B5D@chatbase.com>
Jonathan Stowe wrote:
>
> TRG Software : Tim Greer <webmaster@chatbase.com> wrote:
> > Tom Christiansen wrote:
> >>
> >> I have an idea. When someone asks a questions that's in the standard
> >> perl manpages, we'll all simply mail them the complete manpage. :-)
> >
> > Unfortunately, you still can't make them *read* it in their email,
> > anymore then you can on their system. People usually skip over reading
> > help pages, go to the bottom and contact the author and ask what's on
> > the page anyway. Why waste the bandwidth? :-)
> >
>
> Ok, to tie this all together then we send them an MP3 file of someone *reading*
> the relevant documentation.
>
Naw, an AVI file would be bigger and lessen the chances of them wanting
more. :-)
Perhaps it's time to develop a chip to implant in their brains? Just the
docs and charge a small amount for uploading the new information. Just
an idea. I'm not sure what else to offer, other then "programming" it
into their brains, nothing else seems to work.
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.
------------------------------
Date: Mon, 21 Jun 1999 19:52:19 GMT
From: paulm@dirigo.com
Subject: Database Manipulation
Message-Id: <7km55d$jv0$1@nnrp1.deja.com>
I currently have a internal website that runs a perl script that will
pull that values of a sales forecast from our database into a dynamic
web page via DBI and an SQL string. What I want to do now is give the
sales people the ability to edit their specific forecasts via the web.
The forecast is currently only viewable. I want to right a script that
will grab all the values that the "view" script pulled out of the
database and put them into a text box. Then I can set the script up to
use an SQL string (UPDATE) to update the sales forecast.
Pretty simple right? Well, if you know please give me a hint :)
--
Paul R. Mesker
System Engineer
Dirigo Inc.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 21 Jun 1999 14:52:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Docs for cmdline switches - where?
Message-Id: <376EB412.D6442974@mail.cor.epa.gov>
Mark Holmes wrote:
>
> Where can I find documentation for Perl's command line switches?
> I can't find this anywhere in the manpages or faqs. There are
> scattered references (esp. for -w ;^) in the shipped docs but I
> could see no official writeups for the switches shown on the very
> first lines of perl.pod. I divined some like -d and -e but am
> daring to want it all.
It's in perlrun. If you think about it, it makes sense.
> Also, I'm new to this NG and am wondering if y'all find it safe
> to post with your real reply addresses? Do the spambots haunt us
> here? I'll look in the group for any replies to this post, but
> to reply directly remove 'no.spam' from my address. I have
> somehow managed to keep this mailbox completely spam-free and
> want to savor the moment! Thx,
Go ahead. Take that no.spam out of your address. Don't cower
before slimy spammers. "Take arms against a sea of troubles,
and by opposing end them." Or do like Philip Newton, and
just plain outwit the spambots. I've gotten perhaps four spams
this year. Each time I just check their headers, find their
actual sending address, and let their ISP sh!#can them.
And Spamford Wallace's ISP is forbidden by our network
admin, so we don't see anything from there - so maybe I've
dodged a couple bullets.
And anyone stupid enough to spam Tom Christiansen deserves
what they get. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 21 Jun 1999 15:32:40 -0500
From: "David W. Brock" <dwbrock@veribest.com>
Subject: Embedding problem w/ perl_parse()
Message-Id: <zZre7RCv#GA.153@pet.hiwaay.net>
I am embedding Perl in a C++ program on Win32 using version 5.004_02. The
program has a GUI which runs a perl script. I have a problem in that
whenever perl_parse() fails because of a syntax error, the perl interpreter
appears to keep the perl script file open. I know this because as long as
my program is running I cannot modify and save the file - the file editor
tells me
that the file is in use by another program.
I am calling perl_destruct() and perl_free() after the perl_parse() failure,
but this does not seem to help. Is there some other function that I can
call to get perl to close the file?
Is this a bug?
David
------------------------------
Date: 21 Jun 1999 21:41:50 GMT
From: pdf@morgan.ucs.mun.ca (Paul David Fardy)
Subject: Re: Good reasons for avoiding modules (was: Re: Afraid to ask about Y2K!)
Message-Id: <7kmbiu$i5l$1@coranto.ucs.mun.ca>
abigail@delanet.com (Abigail) writes:
>So, what should not be in the core then? Should be start with putting
>everything in CPAN in the core?
That's extreme. I might ask "Should we remove localtime, gmtime,
getpw* from the core?" They could be supplied as modules; they don't
need to be in the core. I would think we'd use some metric of
reasonable: put in the core what would reasonably desired to be there.
Some are suggesting that it's reasonable to want, in the core, a
variant of localtime that uses a more universal epoch than 1900.
Is it just me? I like that we don't have to specify "-lS -lc" to
the C compiler. I occasionally to forget to add "-lm" when it's
needed.
Of course, it would be nice if we could promote some CPAN modules
into a standard library distribution.
Paul Fardy
------------------------------
Date: Mon, 21 Jun 1999 21:29:29 GMT
From: akhazano@oacis.com (Andrew Khazanov)
Subject: Having an external script modify %ENV?
Message-Id: <3770a9a7.10117167@news.isp.net>
I'm writing a Perl GUI script that will sit on top of a bunch of
currently existing Korn shell scripts and run them in a certain
sequence, with certain parameters, etc. etc. Some of these scripts
need to set environment variables which are then used by other
programs. Now, in ksh, you can execute a script in the current
shell's environment by using the dot -- all exported variables stick
around. Is there a way to do the same from Perl -- have a script
called by Perl modify its %ENV (I hope I hope I hope). If that's not
possible, is there a better solution than parsing the scripts myself
and "manually" setting each variable?
Thanks a lot,
Andrew Khazanov
------------------------------
Date: 21 Jun 1999 21:54:55 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Having an external script modify %ENV?
Message-Id: <7kmcbf$is7$2@info2.uah.edu>
In article <3770a9a7.10117167@news.isp.net>,
akhazano@oacis.com (Andrew Khazanov) writes:
: Is there a way to do the same from Perl -- have a script
: called by Perl modify its %ENV (I hope I hope I hope).
Do you want changes in %ENV to be visible to subprocesses?
[16:52] ettsn% perl -e '$ENV{FOO} = 'bar'; system "echo \$FOO"'
bar
If you're wanting the changes to go the other way, read the FAQ. I'm
told VMS lets you do this sort of thing, but you don't sound that
desperate. :-)
Greg
--
If the human brain were so simple that we could understand it, we would be so
simple that we couldn't.
------------------------------
Date: Mon, 21 Jun 1999 20:48:04 GMT
From: portboy@home.com (Mitch)
Subject: Help with timing out an operation....(My broken code included).
Message-Id: <376e3491.241356502@24.0.3.71>
Okay, when my script start up, it provides you with a prompt requiring
you to enter your password. Assuming the password is valid, it then
sends you to a command prompt. prompt> What I'm to do is, if they
are at the prompt for say 5 seconds, and they haven't entered
anything...I want to call a subroutine that will log them out. When
they are logged out, they are returned back to my password prompt
where it can sit there for forever.
I've been trying to work from the example shown in the Perl Cookbook,
and it works to some degree, but I'm still having trouble. The
trouble is, when they get to the "prompt>" it will sit there for five
seconds and then log the user out, however, when I try to type a
command at my "prompt>" it immediately exits the script. Can someone
explain to me why this is happening?
Here's the jist of my code:
$SIG{ALRM} = sub { die "timeout" };
sub commands {
while (1)
{
&timer; # The commented lines below is how I used to
show the prompt. the &out subroutine is nothing more than a "print
shift" statement.
# ($delta == 1) {
#&out(&prompt2);
#} else {
#&out(&prompt);
#}
#my($an) = &get_line;
#($cmd, @args) = split(/\s+/, $an);
# all lines below here at nothing more than a call to
the various command subroutines.
&{$command{sub}}(@args);
}
}
sub timer
{
eval {
alarm(5);
if ($delta == 1) {
&show(&prompt2);
} else {
&show(&prompt);
}
my ($an) = &get_line;
($cmd, @args) = split(/\s+/, $an);
alarm(0);
};
if ($@ =~ /timeout/) {
&logout; # returns the user to the password prompt.
} else {
alarm(0);
die;
}
}
So, what am I doing wrong?
------------------------------
Date: Mon, 21 Jun 1999 20:10:15 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: How do I delete lines from a file
Message-Id: <H_wb3.6413$36.118574@news2.rdc1.on.home.com>
In article <376E986D.B860900B@computer.org>,
Carter Hamilton <carter@computer.org> wrote:
! I am a beginner in PERL programming. None of the references I have
! demonstrate how to remove lines from a file. What I am attempting to do
! is open a text file, delete certain lines from the file, then close it.
! Does anyone know how to do this?
One reference you should have is the perl FAQs included with
every perl distribution --- you need to locate this information
and learn to search it effectively. If you do so you should
find the following entry in section 5 of the faq:
perlfaq5.pod: How do I change one line in a file/delete a line
in a file/insert a line in the middle of a file/append
to the beginning of a file?
try reading perlfaq5 with:
perldoc perlfaq5
then try:
perldoc perl
perldoc perlfaq
regards
andrew
------------------------------
Date: Mon, 21 Jun 1999 22:06:57 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Interpreting MS-ASCII - anyone have a filter?
Message-Id: <Pine.HPP.3.95a.990621214805.5311G-100000@hpplus03.cern.ch>
On Mon, 21 Jun 1999, Bart Lateur wrote:
> >MS have a
> >tendency to refer to their 8-bit codings as "ANSI", but I've never found
> >anything from the ANSI that justifies this usage, either.
>
> But yes. Windows uses a superset of ISO-Latin-1, AKA "Ansi",
Sure, we all know that...
> which is the same as most Unices use.
I don't agree. The unix variants that I've ever used were based on
either DEC Multinational or iso-8859-1. None of them had displayable
characters in the 128-159 range.
But this isn't the point...
Which published standard have you found from the American National
Standards Institute which lays down these codes, please? Without one
of those, I don't see any authority for applying their name. I hunted
around the ANSI's web site but failed to find anything relevant. It
looks as if they backed-out of publishing USA national standards for
character codings after US-ASCII (7-bit code) had finally been settled;
one might surmise they decided that international data transfers were
too important to have a specifically USA standard. If someone can
throw more light on the history I'd be interested, but a Perl language
issue it ain't, I must confess.
all the best
------------------------------
Date: 21 Jun 1999 19:37:32 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Interpreting MS-ASCII - anyone have a filter?
Message-Id: <7km49s$7c4$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Alan J. Flavell <flavell@mail.cern.ch> wrote:
> Just check that the "euro" has been included,
I'm not sure if thats such a worry - I still havent figured out how to bring
forth the character from the newfangled euro enhanced keyboard at work -
but hey its an opportunity for a new special variable in Perl ;-}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 21 Jun 1999 21:40:09 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Interpreting MS-ASCII - anyone have a filter?
Message-Id: <3770af34.1833396@news.skynet.be>
Alan J. Flavell wrote:
>Which published standard have you found from the American National
>Standards Institute which lays down these codes, please? Without one
>of those, I don't see any authority for applying their name.
I see. Actually, it's an ISO standard (International Organization for
Standardization), of which Ansi (American National Standards Institute)
is a member. Americans may be find this offending, but that means that
such an ISO standard carries even more weight than "just" an Ansi
standard. (<http://www.iso.ch/infoe/intro.htm>)
Bart.
------------------------------
Date: 21 Jun 1999 21:47:21 GMT
From: rdawes@mariska.rogan.org ()
Subject: Modem control in perl?
Message-Id: <slrn7mtcnu.mv.rdawes@mariska.rogan.org>
Keywords: modem serial war-dial ioctl
Hi folks,
I am trying to control a modem from a perl script. I have successfully
managed to talk to the modem, issue commands, receive input, etc. I am
pretty happy with it so far.
However, I have one nagging problem that I do not know how to solve:
How do I raise or lower DTR(?) to make the modem hang up?
I have tried to use the '+ + + AT' (without the spaces) and it works on
one modem, but not on the next. I believe that dropping DTR (or one of
the lines) is the correct way to force a modem to drop the connection.
I think it should also be more reliable. Is this something I should be
trying to use an IOCTL for?
Does anyone have any suggestions as to how I can go about doing this? I
am using Linux 2.0.34, and Perl version 5.00404 (I think)
Much thanks.
When this is complete, I will be releasing source, as I have not seen
any good code for driving a modem under perl, so bad code will at least
be something :-)
Rogan
P.S. Mail would be appreciated, but I will be trying to read this group as
well.
--
Rogan Dawes rdawes@intekom.co.za
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare.
Win 98 source code? Eight monkeys, five minutes. Tops.
------------------------------
Date: Mon, 21 Jun 1999 20:37:06 GMT
From: Darrin Edwards <d-edwards@uchicago.edu>
Subject: Re: multidimensional arrays with functions push and pop
Message-Id: <tgwvwxwarx.fsf@noise.bsd.uchicago.edu>
cdmafleet@aol.com (CDMAFleet) writes:
> I'm having trouble with getting Perl to see what I want it to see.
>
> Let's say you've got a multidimensional array
[snip]
> things, then the multidimensional array would look something like this:
>
> @myarray = ( [], [], [], [], [] ... and so on).
>
> You could do this through a for loop it seems. (Which is actually how I
> create the blank startup array.)
>
> for ($i = 0; $i < $number_of_login_ids; $i++)
> {
>
> @myarray = (@myarray, []);
>
> } # end for loop [$i]
>
> (PS. If my code looks funny, I'm a C coder first, then a Perl scripter
> next!)
You can "hide" the for loop in a somewhat more perlish fashion:
@myarray = ([]) x $number_of_login_ids;
(Read the "perlop" manpage to find out about the "x" operator. But see
below to find out why you probably don't need it here...)
> Now let's say I want to add an element to the third sub-array.
> So I want to access $myarray[2][?]. More specifically, I'd like to "push" an
> element on the end of that array.
>
> push ( ($myarray[2]), $data);
[snip]
Other posters in this thread have pointed out that the syntax for this is
push (@{$myarray[2]}, $data);
But note that even if $myarray[2] was undefined, the above syntax
would still be legal; i.e., you don't need to "initialize" the
elements of @myarray to be empty array refs. Read "perlref" to find
out how this (autovivification) works. (It doesn't even cause "-w"
noise! Read "perlrun" if you don't know what that means.)
[snip other questions answered by other posters]
Darrin
------------------------------
Date: Mon, 21 Jun 1999 19:42:18 GMT
From: mark@bstar.net
Subject: Need Perl Help? (programming/modify script/install script/ etc.)
Message-Id: <7km4in$jla$1@nnrp1.deja.com>
Hi,
I can help you with anything having to do with Perl CGI scripts -
making them (programming), modifying an already made script to fit your
needs, installing a tricky script on your server, or whatever you might
need. I'm a freelance programmer, and I can do whatever you need. My
rates are based on what -you- think is reasonable. Please email me at
mark@bstar.net, with your job.
Sincerely,
Mark Knickelbein
Spammers will be prosecuted
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 21 Jun 1999 18:42:34 GMT
From: dotero@photocircuits.com
Subject: ODBC and CGI
Message-Id: <7km12n$i1t$1@nnrp1.deja.com>
I am writing a CGI script that will use Win32::ODBC to connect to an Access
database. Connecting to the database and running select statements run fine,
but I am having a problem with an insert statement. I keep on getting the
following error every time I try to insert into the database:
error=Error
running sql statement: [-3035] [1] "[Microsoft][ODBC Microsoft Access 97
Driver] Operation must use an updatable query." sql=update TSE_Name set
Email = 'dotero@photocircuits.com' where Username = 'davotero'
The Server is
configured with IIS and the DSN is a system DSN. If I run the script from my
Win95 machine, the statement works fine. I don't understand the return
message that the Server is returning. Any help would be appreciated.
Thanks,David
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 21 Jun 1999 13:41:47 -0700
From: "Rich G." <rg@fubar.net>
Subject: Re: ODBC and CGI
Message-Id: <7km843$obh$1@birch.prod.itd.earthlink.net>
dotero@photocircuits.com wrote in message <7km12n$i1t$1@nnrp1.deja.com>...
>I am writing a CGI script that will use Win32::ODBC to connect to an Access
>database. Connecting to the database and running select statements run fine,
First problem: Use DBI, Use DBD::ODBC, instead of Win32::ODBC. You'll be
glad you did. Then, make sure you check every prepare() and execute() with
and '...OR die("Error preparing/executing: $DBI::errstr")', which will tell you
a lot
more about the errors that you're getting. See the DBI FAQ for more info.
>but I am having a problem with an insert statement. I keep on getting the
>following error every time I try to insert into the database:error=Error
>running sql statement: [-3035] [1] "[Microsoft][ODBC Microsoft Access 97
>Driver] Operation must use an updatable query." sql=update TSE_Name set
>Email = 'dotero@photocircuits.com' where Username = 'davotero'The Server is
Ummm... that's not an insert statement, it's an update. Is that why it's not
happy, perchance?
It could be any number of things. I would really switch to DBI and see if
you're still
getting the problem.
HTH,
Rich G.
------------------------------
Date: Mon, 21 Jun 1999 20:12:25 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: perl help
Message-Id: <FDp1Gp.AEt@presby.edu>
Sunitha <nsunitha@cse.unl.edu> wrote:
(By the way, it really helps *us* when people use a "Subject:" line that's
a bit more specific than "perl help". How about something like "How to
create hashes?" :-)
>I am reading line by line.Splitting the line for name and marks.
>so, $name, $marks has the respective values.
>
>I am unable to do this:
>
>now, i want to create a hash-table of values.
>%marksheet where names is the key and marks is the value.
>Each value of name and marks read from the file.
$marksheet{$name} = $marks;
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[ Information about newsgroups for beginners: ]
[ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]
------------------------------
Date: Mon, 21 Jun 1999 14:50:09 -0700
From: "Ron Lukawitski" <luka@islandnet.com>
Subject: Please Help with Perl 5
Message-Id: <7kmboa$mv9$1@news.islandnet.com>
I'm in real need of some serious help and hoping that I can find it here. I
need to know if Perl 5 is capable of compiling the information from the
enclosed e-mail responses to a musicians (Bass Players)
survey that I am conducting on the internet. I have well over 1'000
responses and they all pretty much look like the 2 samples below.
I need Perl to compile the following:
fretted/fretless: (choose) FRETTED or FRETLESS
bass : (choose) 4, 5 or 6 string bass
name : (choose) any text
acoustic : (choose) YES or NO
I'll end up with 12 catagories and 2 extra (one for total responses and the
other for (name:) those that double on other instruments.
I'm new to Perl programming and would really appreciate all the help I can
get. I just bought the latest Perl 5 For Dummies which I really
enjoy.
THANKS..Ron Lukawitski
http://www.islandnet.com/~luka/lessbass.htm
S A M P L E
","nobody@islandnet.com","nobody@islandnet.com","SMTP","luka@islandnet.com",
"luka@islandnet.com","SMTP",,,,,,,,,"Normal",,"Normal"
"Form Results","Date : Fri Jun 18 22:09:46 1999
Remote Host : dyn3247a.dialin.rad.net.id
Email : nobody@islandnet.com
fretted/fretless: FRETTED
bass : 4string
name :
acoustic : YES
","nobody@islandnet.com","nobody@islandnet.com","SMTP","luka@islandnet.com",
"luka@islandnet.com","SMTP",,,,,,,,,"Normal",,"Normal"
"Form Results","Date : Sat Jun 19 22:28:27 1999
Remote Host : tnt1-c2-235.sao.zaz.com.br
Email : nobody@islandnet.com
fretted/fretless: FRETTED
bass : 4string
name : 5 strings
acoustic : NO
S A M P L E E N D
--
Electric Bass Lessons On The Net
Ron Lukawitski
http://www.islandnet.com/~luka/lessbass.htm
------------------------------
Date: Mon, 21 Jun 1999 21:25:13 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Problem with DB_File
Message-Id: <Z4yb3.153$Rj1.46768@typhoon-sf.snfc21.pbi.net>
In article <7km05g$8eo$1@lublin.zrz.tu-berlin.de>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:
>>Well, I'm having a whale ( tr/aew/el/d ) of a time debugging this
>>DB_File application. I'll reproduce a complete demo script at
>
>Well, apparently there is indeed a bug in some versions of Berkeley DB.
>Paul Marquess, whom some of you may know, sent me mail to that effect,
>saying that he could reproduce the buggy behavior with v 1.85, but
>not with 2.7.5. The version I used is 2.0.7, so apparently it was
>fixed some time in between.
There are other even more vicious bugs in 1.85. I was able to provoke
core dumps with a 10 line script which just assigned progressively longer
values to one hash key - the core dumps occured before reaching a value
length of 6k chars. That was in addition to having the size of the
database explode into the multi-megs going from string length 1 to
string length 5000 chars. One key just progressively assigned '1 more
character' values. Boom. :(
--
Benjamin Franz
------------------------------
Date: Mon, 21 Jun 1999 20:44:36 GMT
From: portboy@home.com (Mitch)
Subject: Re: Question about TTY's...
Message-Id: <376e3357.241042590@24.0.3.71>
On Mon, 21 Jun 1999 10:32:38 -0700, Andrew J Perrin
<aperrin@mcmahon.qal.berkeley.edu> wrote:
>Well, if I understand you right you're worried about a sort of loop where
>you'll be simply receiving echoes of your own transmits.
Well, here's the situation. When the script starts up, it opens two
tty's - probably tty00 and tty01.
Now, the only way the user has access to my script's commands is if
they plug directly into the serial port. This is where there could
possible be a "short" of RX and TX. They could be plugging in some
modem that does nothing but echo crap.
>checking this periodically (or perhaps just once at the beginning),
>something like:
>
>print "$$.testpacket.$$\n";
>
>and see if you get it back Including the $$ (the script's pid) will give
>you a pretty good chance that your remote machine doesn't happen to be
>sending that string by chance; if you're worried you could make it more
>unique, say by squaring, cubing, etc., the pid.
I'm not exactly sure what you mean here. How could I do this in some
sort of loop that happened like every 60 seconds or so? Any
suggestions?
Regards, mitch
------------------------------
Date: Mon, 21 Jun 1999 15:04:08 -0500
From: ktb <xyf@inetnebr.com>
Subject: Return value in script.
Message-Id: <376E9AB8.EEAB7038@inetnebr.com>
Hi, I have this script that I can search a file of mine. The script
works fine but I'm trying to get it to print "No string found." if the
search is not sussessful. The entire script is below but it's this part
I'm working with:
________________
sub result {
if($& lt 1) {
print "No string found.\n";
} else {
print "\n$_\n";
}
}
_________________
This subroutine will not print "No string found." if the search is not
successful ie. when I type something like "l;kaa" which the file doesn't
contain. If I change the line to, if($& gt 1) it will print the line as
many times as the search sucessfully finds what it's looking for. When
I just hit return twice (enter nothing to search for) I get "No string
found." printed several times. Anyway maybe there is a better way of
doing this? I've screwed around with "return" and can't get anything to
work. Any thoughts would be apreciated.
kent
_____________________________________________________________________________
#!/usr/bin/perl -w
use strict;
my ($SearchString, $parts, $PartsFile, @parts, $search, $OutPut);
print "Enter string to search: ";
chomp ($SearchString = <STDIN>);
open (BottleFile, "botglass.txt") || die "Can't open \"botglass.txt.\"
$!.\n";
while (<BottleFile>) {
@parts = split(/\t/);
if(! defined ($PartsFile = $parts[0])) {
next;
}
if ($PartsFile =~ /\Q$SearchString/i) {
result();
}
}
###
sub result {
if($& lt 1) {
print "No string found.\n";
} else {
print "\n$_\n";
}
}
_____________________________________________________________________________
------------------------------
Date: Tue, 22 Jun 1999 17:55:11 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: Search script performance
Message-Id: <3770063F.8A5FB9B2@ingress.com>
[posted and emailed]
rumple1000@my-deja.com wrote:
>
> Hi,
>
> I have a Perl search script which takes a long time to find keywords in
> a bunch of files.
>
> The html files are about 3000 (about 2-3k each) and are stored a very
> complicated and deep structure of nested subdirectories.
>
> Would this structure of subdirectories affect the performance of the
> script which uses find.pl inside it to recurse all the subdirectories?
>
> Would this search be faster if all the files were stored in one
> directory?
You might consider using an indexing search engine to drastically improve
overall performance.
Perhaps something such as SWISH-E for the backend indexer and a Perl front-end
to initiate a query and format the results.
For info on SWISH-E:
http://sunsite.berkeley.edu/SWISH-E/
If you have a significant number of files and/or relatively large files which
need to be searched in an effient manner, an indexed search will always
outperform a brute force realtime search.
--
Ethan H. Poole **** BUSINESS ****
ehpoole@ingress.com ==Interact2Day, Inc.==
(personal) http://www.interact2day.com/
------------------------------
Date: Mon, 21 Jun 1999 16:56:11 -0500
From: Jeff Epstein <exujep@exu.ericsson.se>
Subject: sorting on 2 fields
Message-Id: <376EB4FB.439C5FDF@exu.ericsson.se>
Hi,
I'm writing a sports program and need to be able to sort my table on 2
or 3 fields.
I have Wins, Losses, Ties, PF (points for), etc. I'd like to sort on
Wins-Ties-PF,
or alternatively, I could combine Wins+Ties by 2W+T = Points, and then
sort on Points
and PF.
My array rows look like:
TeamA|11|4|1|430
TeamB|11|4|1|435
TeamC|12|4|0|465
How do I sort so that the standings seen are C B A in this case?
(C has the best record of 12-4, while A&B have identical records but B
has
more points.)
I've looked at
http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_sort_an_array_by_anyth
and it's associated links but I don't understand how to make it work.
Thanks,
Jeff
------------------------------
Date: Mon, 21 Jun 1999 20:17:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <376e9cd7.236836@news.skynet.be>
Greg Bacon wrote:
> I though about fixing it to catch Abigail's quoting
This has been brought up before. In fact, *I* brought it up before. :-)
Abigails quoting starts with one of:
* 2 identical non-word characters (but not space)
* a set of matching "parens", such as "()","<>","[]","{}"
* Two capital i's. I've seen this only once, and honestly, I think this
was a mistake.
Fixing the processing to check for this could bring the speed of it down
quite a bit... Nah...
Bart.
------------------------------
Date: 21 Jun 1999 20:44:37 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <7km87l$i2h$1@info2.uah.edu>
In article <376e9cd7.236836@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) writes:
: Greg Bacon wrote:
: > I though about fixing it to catch Abigail's quoting
:
: Abigails quoting starts with one of:
:
: * 2 identical non-word characters (but not space)
: * a set of matching "parens", such as "()","<>","[]","{}"
: * Two capital i's. I've seen this only once, and honestly, I think this
: was a mistake.
The third came about as a way of showing that she would be able to
beat even something like /^[[:ispunct:]{2}/. It's just a heuristic.
It's not always going to work, but it's good enough for most cases.
If someone is sufficiently determined to appear to have a high OCR,
then there really isn't much I can do to stop him. No, I'm not going
to sit and do it by hand. :-)
: Fixing the processing to check for this could bring the speed of it down
: quite a bit... Nah...
I don't think it would make a huge difference in performance.
Greg
--
A lot of people mistake a short memory for a clear conscience.
-- Doug Larson
------------------------------
Date: Mon, 21 Jun 1999 13:48:12 -0700
From: Raj <technology@workmail.com>
Subject: system call
Message-Id: <376EA50C.E33CDE9A@workmail.com>
Hi,
I have a shellScript "prog.sh". How do i call this from within my
CGI/Perl Script??
I used system command but it is not executing at all. Any help
please!!!! TIA,
Raj
------------------------------
Date: Mon, 21 Jun 1999 13:01:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: To obfuscate or not?
Message-Id: <MPG.11d839d55da4ccf5989c10@nntp.hpl.hp.com>
In article <7km3p5$gm6$4@info2.uah.edu> on 21 Jun 1999 19:28:37 GMT,
Greg Bacon <gbacon@itsc.uah.edu> says...
> In article <376e8cc8@diana.idirect.com>,
> "Carey Barnett" <cbarnett@idirect.com> writes:
...
> : Terse, and thereby cryptic, code used to save bytes and speed in the
> : executable, so... Does terse Perl save processing time? It certainly isn't
> : required with modern compilers and other languages.
>
> Perl hackers like to play Perl Golf (fewest strokes wins!) with each
> other because it's fun and not because the code will necessarily run
> faster. Perl Golf is also a way to start Yet Another Benchmark War. :-(
As you know, there's more to it than that. Prolix Perl code is slow by
its very nature, because of the overhead of instruction dispatch.
Character-at-a-time or aggregate-element-at-a-time processing is slow
compared to functions such as grep and map.
Terseness counts -- usually. That's what the benchmarks are for.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 21 Jun 1999 20:34:01 GMT
From: portboy@home.com (Mitch)
Subject: Re: Trying again...
Message-Id: <376e2dec.239655286@24.0.3.71>
>What is thist %$config business? Is there something you're not telling
>us?
Sorry, just a mistake I made is copy/pasting stuff over.
>Here's a program that works more or less as I think you expect:
>
> #! /usr/bin/perl -w
>
> use strict;
>
> use Carp;
>
> my %config;
>
> sub read_config {
> my $cfg = shift;
> local $_;
>
> open CFG, $cfg or croak "$0: failed open $cfg: $!";
>
> while(<CFG>) {
> chomp;
>
> s/#.*//;
> s/^\s+//;
> s/\s+$//;
>
> next unless length;
>
> my($var, $value) = split ' ', $_, 2;
>
> #$config{$var} = $value;
> ++$config{$var};
> }
>
> close(CFG);
> }
>
> read_config "file";
>
> my($var,$value);
> while ( ($var,$value) = each %config) {
> print "$var: $value\n"
> }
>
When I tried printing the stuff out with the code above i got:
foo: 1
pepsi: 4
coke: 1
pass: 1
>
>Assuming you want only one value with each keyword:
I would like for there to be multipe values per keyword. So assume
that a keyword exists of coke, I need to be able to values of bites,
sucks, rules, whatever. So in the config it would look like:
coke bites
coke sucks
coke rules
coke whatever
>
> sub read_config {
> my $cfg = shift;
> local $_;
>
> open CFG, $cfg or croak "$0: failed open $cfg: $!";
>
> while(<CFG>) {
> chomp;
>
> s/#.*//;
> s/^\s+//;
> s/\s+$//;
>
> next unless length;
>
> my($var, $value) = split ' ', $_, 2;
>
> $config{$var} = $value;
> }
>
> close(CFG);
> }
>
This doesn't fulfill the requirements I want. This will make the last
read value of coke as "whatever". This is bad cuz I need to know
about sucks, rules etc.
>If you want to associate an array of values with each keyword, change
>
> $config{$var} = $value;
>
>to
>
> push @{ $config{$var} }, $value;
>
>and use this to print it
>
> my($var,$value);
> while ( ($var,$value) = each %config) {
> print "$var: [", join("][", @$value), "]\n";
> }
>
>: At the same time, how can I check to see if coke bites already exists?
>
>You could use
>
> if (exists $config{coke}) { ... }
>
>or
>
> if ($config{coke} eq 'bites') { ... }
>
>depending on what you want to do.
Now this is what I wanted. This works great. So now I'm getting the
output of:
drpepper: [sucks]
coke: [rules][bites][foobar][whatever]
pass: [foobar]
Okay, still a couple more questions: How can I add entries to any of
these variable. Like add "rules" to drpepper? Also, how can I delete
"foobar" from coke? Lastly, how can I show only those variable for
coke?
>
>Hope this helps,
>Greg
You damn right it did. Thanks a lot man,
.Vince
------------------------------
Date: Mon, 21 Jun 1999 15:00:07 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
To: Darrell Stec <darstec@aol.com>
Subject: Re: virtualave.net
Message-Id: <376EB5E7.EB06D615@chatbase.com>
[posted & emailed]
Darrell Stec wrote:
>
> In article <376D698D.E9C1DEC4@chatbase.com>, TRG Software : Tim Greer
> <webmaster@chatbase.com> writes:
>
> >Leonid Goltser wrote:
> >>
> >> Somebody suggested me to upload my scripts on virtualave.net. I did but my
> >> scripts do not work (although, they work perfectly on my machine). Browser
> >> can't open them. If somebody use virtualave.net, can you help me? Probably
> >> something wrong with configuration or something else. If you run your
> >> scripts on that server, please, give me a piece of your code what works
> >> there. I'll use it as an example.
> >
> >Isn't it logical to actually go to virtualave.net's web site and take a
> >look at *their* site's help and support pages? This isn't a perl
> >question, you realize that much, don't you? With that said, please don't
> >post such off-topic questions here.
> >--
> >Regards,
> >Tim Greer: chatmaster@chatbase.com / software@linkworm.com
> >Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
> >TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
> >Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
> >Freelance Programming & Consulting, Musician, Martial Arts, Sciences.
> >
> >
>
> Actually it really IS a Perl question, and on-topic. The performance of the
> coding had nothing to do with Virtual Avenue at all, Leonid simply made that
> assumption. There are a few basics missing from the coding, if what I got in
> Email was the complete program.
>
> Later,
> Darrell Stec E-Mail: DarStec@aol.com
>
> Webpage Sorcery
> http://webpagesorcery.com
> We Put the Magic in Your Webpages
Correction; when someone posts saying "I upload my scripts to such and
such free server, they don't work, what's wrong?" is *not* a Perl
question, nor is it "on topic". (Even if they are having a genuine
problem, they need to state such, or it is off topic... Just as if I was
talking about sendmail bugs and security holes, that doesn't mean I
don't have a Perl problem, but it's still off topic until I post
something relevant to Perl. :-)
If he provided some code, or something in his question that actually had
to do with Perl, then I wouldn't have stated such. However, being the
fact that his posts made no mention of Perl, other then the fact that he
was having a problem and he was having this "problem" with a script
coded in Perl, which doesn't mean anything.
I never said he didn't have a problem with his Perl script, but his post
sure didn't have anything to do with Perl, and that's all I said.
Therefore, it was *not* a Perl question and it was indeed off-topic. I
didn't post that to ridicule of flame him, but as he posted that
question, it definitely was off topic. Apparently is would have been "on
topic" if he had posted here what he told you in a private email.
It's good to hear that his problem is solved, although it's usually
polite to post that it's been solved and what the problem was (if it's
indeed relevant to this NG) so people won't continue to try and offer
help still, and further; so others with the same problem can see the
answer before they end up posting the same question. :-)
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 6081
**************************************