[18195] in Perl-Users-Digest
Perl-Users Digest, Issue: 363 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 06:06:39 2001
Date: Tue, 27 Feb 2001 03:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983271908-v10-i363@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 27 Feb 2001 Volume: 10 Number: 363
Today's topics:
calculation of a size of the directory <djusha@infotel.kg>
Re: FAQ 4.73: How do I verify a credit card checksum? (Sam Holden)
Re: FAQ 4.73: How do I verify a credit card checksum? <uri@sysarch.com>
form/cgi help really needed! shorty_helena@yahoo.se
Re: form/cgi help really needed! <bart.lateur@skynet.be>
Re: HELP needed on a simple Parse::RecDescent program ( <ekliao@pacbell.net>
Re: How do I test whether a CODE reference is an NOP? <bart.lateur@skynet.be>
How the CLPM turns (Bernard El-Hagin)
Re: How they learn ( previously: Please Help with 10 l <parrot0123@yahoo.ca>
Re: Looking for advice from seasoned Perl experts <jonni@ifm.liu.se>
Re: Looking for advice from seasoned Perl experts (Logan Shaw)
Off-topic: generating Excel _sheets_ (EED)
Perl CGI and Apache under Win98/NT <knap@firma.2p.pl>
Re: Please Help with 10 line programm -- beginner quest <bart.lateur@skynet.be>
Re: Please Help with 10 line programm -- beginner quest <taka@yarn.demon.co.uk>
Re: receiving piped input??? <lanaS55nospam@hotmail.com>
Re: Script Problems - Please Help <c_clarkson@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Feb 2001 15:55:04 +0500
From: "Andrej Kartashov" <djusha@infotel.kg>
Subject: calculation of a size of the directory
Message-Id: <97g11g$9h1$1@alpha.elcat.kg>
Hello,
I try to use the following code for calculation of a size of the directory:
*******************************************
while(defined($file= <${DATADIR}/_qry/*>)){
$catSize += -s $file}
*******************************************
This working code but if we have many files in the directory then it takes very lot
time....
Probably somebody has more beautiful idea, or any system command...
This will work on Linux but it would be desirable that it worked on W2K as well...
Thank you in advance
Andrej
------------------------------
Date: 27 Feb 2001 05:53:35 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: FAQ 4.73: How do I verify a credit card checksum?
Message-Id: <slrn99mg6v.hik.sholden@pgrad.cs.usyd.edu.au>
On Mon, 26 Feb 2001 20:45:36 -0800,
Kiralynne Schilitubi <callgirl@la.znet.com> wrote:
>PerlFAQ Server wrote:
>
>> How do I verify a credit card checksum?
>
>> Get the Business::CreditCard module from CPAN.
>
>
>Coding for this can be accomplished in just under
>fifty lines of code, even less if obfuscated, and
>it is very simple code.
The module does what the question asks in signifacantly less than
fifty lines of very readable non-obfuscated code. Maybe you should
take a look and find out why it would take you so much more code.
>
>A more accurate FAQ, a more realistic FAQ would
>include a suggestion similar to,
>
>"You may also research and learn from this module
> then write your own code. This is not difficult
> and could be customized to suit your needs,
> more specifically and more efficiently."
Since the code in Business::CreditCard is under 50 lines and does exactly
what the question asks (verify a cc checksum (it does one other thing as well),
what would be the point of writing your own code - it isn't going to be any
more efficient, and it can't be more specific since the module exactly
answers the question.
Plus when a new credit card type comes into use you might have to remember
to modify your code (assumming you find out about it), whereas using the
module (not just lifting the code) means there are a lot more people who
might notice and add the new card type that you then get to support...
--
Sam Holden
------------------------------
Date: Tue, 27 Feb 2001 06:16:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 4.73: How do I verify a credit card checksum?
Message-Id: <x7y9usfy5p.fsf@home.sysarch.com>
>>>>> "SH" == Sam Holden <sholden@pgrad.cs.usyd.edu.au> writes:
SH> Plus when a new credit card type comes into use you might have to
SH> remember to modify your code (assumming you find out about it),
SH> whereas using the module (not just lifting the code) means there
SH> are a lot more people who might notice and add the new card type
SH> that you then get to support...
don't waste your breath on moronzilla and modules. she uses them and
then slams the use of them. maybe she would be more convincing if she
just posted code that did all the things that she used modules for. or
ever worked in a commercial IT shop where her code (if you can call it
that) was shared and wasn't in a module. "cut and paste it in if you
want to use it". she would last long there.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 27 Feb 2001 08:21:33 GMT
From: shorty_helena@yahoo.se
Subject: form/cgi help really needed!
Message-Id: <97fo2d$fef$1@news.netmar.com>
Okay, so I realize this is really more of a html/form problem, but the form
is outputted by a perl/cgi script and I haven't been able to get help from
anywhere else...
WHAT I AM DOING:
- A cgi program searches through a stocklist and displays data about the found
products: part #, quantity, price, manufacturer, date code, package.
This is done with a foreach loop, and there could be any number of lines
outputted.
- Quantity and price are in text fields, so the user can change them.
- At the end of the line, there is a checkbox, which holds the values that are
constant (part #, manufacturer, date code, package)
- The user is supposed to check the box at the end of the line with certain
products, and if they want to, change quantity and price.
PROBLEM:
- Aaargh! It's all messed up!
- No matter how many boxes you check, the information sent is:
* all price fields
* none of the quantity fields
* value of the checked boxes
QUESTION:
- Can I somehow make the checkbox apply to all the fields on the line?? Or can
I do this some other way?
You can see the script in action at
http://emelin.virtualave.net/searchystocky.htm
(enter...let's say 0805J1000 or any random numbers...)
Relevant code:
open (STOCK, "stock.csv") or die "The database could not be accessed, please
try again later.\n";
@stock = <STOCK>;
foreach $item (@stock) {
if ($item =~ /$FORM::part/ig) {
@array = (@array, $item);
$rfq=a0;
$qty=0;
$tpr=00;
foreach $match (@array) {
($partnr,$quantity,$manufacturer,$datecode,$package) = split(/,/, $match);
$rfq++;
$qty++;
$tpr++;
}
if ($partnr =~ /$FORM::part/ig) {
print "<td><font face=verdana size=1>$partnr</td>";
print "<td><font face=verdana size=1><input type=text size=5 name=$qty
value=$quantity></td>";
print "<td><font face=verdana size=1>$manufacturer</td>";
print "<td><font face=verdana size=1>$datecode</td>";
print "<td><font face=verdana size=1>$package</td>";
print "<td><font face=verdana size=1><center><input type=text size=5
name=$tpr value=0.00></td>";
$result = join(",", $partnr,$manufacturer,$datecode,$package);
print "<td><center><input type=checkbox name=$rfq value=$result></td>";
print "<tr>";
}
}
}
print "<td colspan=6><font face=verdana size=1><b>Couldn't find what you're
looking for?</b> <br>We will do our best to help you! <a href=...>Click
here...</a><p><br></td>";
print "<td><center><input type=submit value=RFQ></form></td>";
print "</td></table><p><br>";
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Tue, 27 Feb 2001 10:22:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: form/cgi help really needed!
Message-Id: <02vm9tg3re2le1qmd4pk5vi5p4a3c3ajpd@4ax.com>
shorty_helena@yahoo.se wrote:
>- No matter how many boxes you check, the information sent is:
> * all price fields
> * none of the quantity fields
> * value of the checked boxes
> print "<td><font face=verdana size=1><input type=text size=5 name=$qty
>value=$quantity></td>";
You must make sure that your input fields have a UNIQUE name for the
whole form. Since you're constructing a table with many items, that
implies that for a field name, you need a combination of the field type,
for example "QTY" with a product identifier, for example the part
number.
print qq[<input name="QTY-$partnr">];
> print "<td><font face=verdana size=1><center><input >type=text size=5
>name=$tpr value=0.00></td>";
> print "<td><center><input type=checkbox name=$rfq >value=$result></td>";
Again, the names are probably not unique.
When parsing the form, you will have to separate the field names into
their composing parts, but that's easy in Perl. A simple split, with an
upper bound of 2, and Bob's your uncle.
$fieldname = 'QTY-123-4567'; #example
my($type, $id) = split /-/, $fieldname, 2;
print "Field type: '$type' product ID: '$id'\n";
-->
Field type: 'QTY' product ID: '123-4567'
You can use grep or map to get a list of product id's.
@ids = map { /^QTY-(.*)/ } keys %form;
Note that here, I use map as a sort of grep: only for those names where
there is a match, $1 (and only $1) which is the product id, is added to
the output list.
--
Bart.
------------------------------
Date: 27 Feb 2001 01:57:22 -0600
From: Eric Liao <ekliao@pacbell.net>
Subject: Re: HELP needed on a simple Parse::RecDescent program (problem: some rules are matched twice)
Message-Id: <g2nm9t812778f1prbsmji5qu8c0842oqtr@4ax.com>
Thanks, Randal and Ren, for your fast response! I got it running
now!
Eric
------------------------------
Date: Tue, 27 Feb 2001 10:27:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How do I test whether a CODE reference is an NOP?
Message-Id: <m20n9tcfl5m9h7r61crjubqu865sqt2e6o@4ax.com>
John Lin wrote:
>I mean NOP by sub {}
>How do I test if a CODE reference is a NOP?
You can't. Perl doesn't allow you to reconstruct source from compiled
code. Although B::Deparse comes pretty close; I don't think ypou can use
it here.
But what you can do, is use the same NOP everywhere.
$NOP = sub {};
$a = $NOP;
$b = $NOP;
print $a eq $b ? 'both the same':'different';
You can also use '==', because a ref in numerical context returns the
address of the location, as a number.
--
Bart.
------------------------------
Date: Tue, 27 Feb 2001 07:49:59 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: How the CLPM turns
Message-Id: <slrn99mn0h.n9t.bernard.el-hagin@gdndev32.lido-tech>
Hi,
After frequenting this newsgroup for over 2 years I've come to know
some of the regular posters here and decided that, as a service to
newbies, I'd write up some typical regular poster replies to typical
newbie questions. That way someone new to the group can pick the style
of answer he/she prefers and look for that person in the future.
DISCLAIMER!
My goal in doing this is not to offend anyone. Quite the contrary,
actually.
__________
Typical newbie question:
Subject: NEWBIE DEMANDS HELP NOW!!!!!!
I'm new to PERL. I want to sort an array, but don't know how. I've spent
hours searching the Web, the docs, the FAQs, the books, and under my
bed, but couldn't find the answer. You must help me NOW or I'll get
fired.
__________
Typical answers:
Randal Schwartz:
Funny you should ask that. I just wrote an article about sorting for my
Web Techniques column. Check it out. <url follows>
__________
Tom Christiansen:
You do yourself a grave disservice by calling yourself a "newbie". Maybe
"beginner" or even "neophyte" would be more appropriate.
__________
Abigail:
That's trivial. Here's the fastest possible solution anywhere ever:
my @sorted = *^&^@#&^*89(&*^@^@#^&*55238&^%&&@#^%%@*^#^@&*^@#^&#@@#
%^&%&^%%&^&%^^@&^#$($)(@$&@#!&*@^#&*!^#*&!#^*&!#!#%!#^()$)@*$@#$)&@
&*(^$@#&*^@$#%^%^&%&%&^%&&(!@$^@$^@$@$(@^$&^&*!*&%!%@#*)$^@&@$%%%%!
@unsorted;
HTH. HAND
__________
Tad McClellan:
It's Perl or perl, not PERL (perldoc perlfaq1). You are expected to read
the standard documentation that comes with your distribution of Perl
before wasting the time of billions of people with a question you could
have answered for yourself. This particular question could have been
answered by simply doing:
perldoc -f sort
Don't forget to enable warnings and strictures even when you're not
writing in Perl. It's *that* important.
__________
uri guttman:
where's that damn shift key!? oh, and godzilla must die!
__________
Martien Verbruggen:
It's not clear from your post what it is you're sorting and how you want
to sort it. If it's a simple ASCII sort you want just use the builtin sort
function:
my @sorted = sort @unsorted;
If, on the other hand, you'd like to sort the array numerically, you'll
have to try something like:
my @sorted = sort {$a <=> $b} @unsorted;
To make that sort ascending just switch $a and $b:
my @sorted = sort {$b <=> $a} @unsorted;
Note that you can also ASCII sort in ascending order like so:
my @sorted = sort {$b cmp $a} @unsorted;
To get more information about sorting read:
perldoc -f sort
perldoc -q 'sort'
__________
Bart Lateur:
my @sorted = sort @unsorted;
__________
Mark-Jason Dominus:
You could change the perl source code to always sort arrays when you
print them.
__________
Godzilla!:
You male chauvinist pig! You dare attack mighty Kira with your mule manure!
I will stomp.stomp.stomp you!
#!/usr/bin/perl
print "Content-Type: text/plain\n\n";
print "Test case follows:\n";
print "The next line will be the test case:\n";
print "Here we go:\n";
@sorted_array = map {$a = $b} @array;
print "Godzilla Rulez!\n";
__________
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 27 Feb 2001 05:07:17 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: How they learn ( previously: Please Help with 10 line programm -- beginner questions Thanks Guys)
Message-Id: <9CGm6.308662$f36.11219979@news20.bellglobal.com>
I know this question wasn't directed at me, I'm a "newbie" so I guess I'll
throw my story in. I learned how to program with Perl mostly through
finding free code on the net and disecting it to see how it ticks. Of
course, I'm a professional programmer, and once you know some languages it's
fairly easy to read one that you don't know. I also read up a bit about it
on webmonkey too, some good tutorials there.
Shane McDaniel <shanem@ll.mit.edu> wrote in message
news:3A9AD404.AEFA51BE@ll.mit.edu...
> I'm just curious but how did you go about learning perl? ie what
> resources and books did you use. I'm just curious how the "newbies" go
> about learning and whether it is flawed or not and how it might impact
> performance. Nothing personal but the && mistake was fairly obvious if
> you had read something about while loops.
>
> mshort wrote:
> >
> > Perl People,
> >
> > Thanks I got it to work.
> >
> > The AND and && both work in the program. The comma doesn't work, it
does
> > exactly what Randall said, it drops the left argument.
> >
> > John,
> >
> > What do you mean "using strict"?
> >
> > Thanks again guys, next lesson is foreach loops and arrays.
> >
> > Sincerely,
> >
> > Matt Short
> > John Joseph Trammell <trammell@bayazid.hypersloth.net> wrote in message
> > news:slrn99l4rf.r0q.trammell@bayazid.hypersloth.net...
> > > On Mon, 26 Feb 2001 13:04:00 -0800, mshort <mshort@usol.com> wrote:
> > > > while ($ans ne 'yes', $ans ne 'no'){
> > >
> > > What test are you trying to perform here? Maybe you should
> > > do some experimenting with this.
> > >
> > > And you're "using strict", right?
> > >
------------------------------
Date: Tue, 27 Feb 2001 08:15:51 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Looking for advice from seasoned Perl experts
Message-Id: <97fk4b$eif$1@newsy.ifm.liu.se>
Some things spring to mind...
1. The scripts will probably run several times simultaniously. Use flock to
avoid conflict when writing to harddrive.
2. Script efficiency. Do 3 or 4 versions of what you think is the
CPU-consuming code in your program. Use the module Benchmark to see which
code is fastest.
perldoc -f flock
perldoc Benchmark (or get the module from http://search.cpan.com if you
don't have it)
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
"Parrot" <parrot0123@yahoo.ca> wrote in message
news:RuGm6.308604$f36.11218381@news20.bellglobal.com...
> Hi,
>
> I'm a computer programmer who'se recently gotten into Perl. I've fiddled
> around with it a little before, but only basically. Now I'm doing some
> really nice work using the language and am generally really pleased with
the
> results I'm getting.
>
> To avoid any confusion, I'm not looking for help figuring out what's wrong
> with some snippet of code. I was tempted a few times but I managed after
a
> lot of hair pulling to figure the problem out for myself, which makes the
> solution that much sweeter. I'm sure, however, that if I was looking for
> that kind of help you people would be right there with the answer for me.
>
> I'm designing a website to handle auctions/messages/e-commerce and stuff
> like that. My employer is anticipating a good amount of traffic to the
> site. I'm generally doing pretty good in making these applications do
what
> I want them to do, but I understand there's some things to keep in mind
when
> designing internet programs that will be getting a lot of traffic. I'm
used
> to designing single-user applications, and was hoping for some advice on
how
> to make my Perl code bulletproof, so that it doesn't crash if too many
> people start accessing the website.
>
> I'm inexperienced at handling things like web servers and how much load
they
> can take and stuff like that - any advice that you guys can give me would
be
> great.
>
> Thanks
>
>
------------------------------
Date: 27 Feb 2001 01:51:28 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Looking for advice from seasoned Perl experts
Message-Id: <97fma0$ih6$1@boomer.cs.utexas.edu>
In article <RuGm6.308604$f36.11218381@news20.bellglobal.com>,
Parrot <parrot0123@yahoo.ca> wrote:
>I'm designing a website to handle auctions/messages/e-commerce and stuff
>like that. My employer is anticipating a good amount of traffic to the
>site. I'm generally doing pretty good in making these applications do what
>I want them to do, but I understand there's some things to keep in mind when
>designing internet programs that will be getting a lot of traffic. I'm used
>to designing single-user applications, and was hoping for some advice on how
>to make my Perl code bulletproof, so that it doesn't crash if too many
>people start accessing the website.
If you stick with CGI, the biggest problem you're going to run into is
that the web server will have to start multiple copies of your script.
This is bad for two reasons.
The first is that Perl scripts take a while to start. You must load
the Perl interpreter, which means loading a whole executable per page.
The disk I/O may be avoided through a cache, but there is still
overhead when the OS starts a new process. Once the interpreter
process has started, it has to initialize itself, and then it has to
load and parse the scripts, and then they have to initialize
themselves. And THEN, finally, the Perl script can start executing.
If you do this whole thing for every page view, you can waste lots of
processor power.
The second is that Perl scripts use lots of memory. They don't use 100
MB a piece (usually!), but even if they only use 10 MB a piece (which
is not unreasonable, depending on what they're doing), then having 100
of them active at a time is going to be a serious drain on your
memory. And, to know how much memory is used by a bunch of processes,
you multiply the rate at which new ones are started by the average time
it takes for one to run from start to finish times the average memory
usage for one. So, if you have CGIs that take 30 seconds to send their
results to slow modem users, and you start one every 1/2 second, you'll
have 60 running at a time.
So, if you have problems with the system getting overloaded when too
many people start accessing the web site, it'll probably be more likely
a result of the site being a CGI-based site than it will be a result of
the site running your particular code.
My point is that if you want scalability, you should put some effort
into learning mod_perl or something like it.
Of course, your code does have *some* effect. Especially if you use
mod_perl -- then it has more effect because you can have memory leaks
and things like that. In general, I think the biggest thing to watch
out for there is that your process doesn't use up more and more
resources (database handles, open files, memory, etc.) the more
requests it serves. This isn't a problem with CGI because the script
exits, but it is something to worry about with mod_perl and so on.
- Logan
--
my your his her our their *its*
I'm you're he's she's we're they're *it's*
------------------------------
Date: Tue, 27 Feb 2001 11:17:31 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Off-topic: generating Excel _sheets_
Message-Id: <3A9B7EBB.C16C0206@eed.ericsson.se>
Hi,
I know that it's easy to generating an Excel
file from a CGI-script by sending the line:
print $query -> header (-type => 'application/vnd.ms-excel');
and then just an HTML-file with HTML-table
(you can even have colored backgrounds).
But is there a way to generate an Excel file with
several "sheets" (ie. small tabs at the bottom)?
Thank you
Alex
------------------------------
Date: Tue, 27 Feb 2001 11:55:36 +0100
From: "Narcyz Knap" <knap@firma.2p.pl>
Subject: Perl CGI and Apache under Win98/NT
Message-Id: <97g0sk$hge$1@news.tpi.pl>
Could you please help me guys. I have installed Apache Server under Win98
and also Win2000 in order to test Perl CGI scripts locally. I set up the
Server Name as 127.0.0.1 and it seems to go on just fine. I can even test
cgi "exe" file that reports the environment variables. However my perl cgis
do not seem to cooperate with Apache server. When I boot them manually
they work just fine. Under Apache I get the error message announcing a
misconfiguration problem. I have even tried an alternative web eserver
program called Xitami, and get the same problem. Please help!!!!!!
------------------------------
Date: Tue, 27 Feb 2001 10:05:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Please Help with 10 line programm -- beginner questions Thanks Guys
Message-Id: <k5um9tcutjsg9a0l2lr9hgiocjf6fsfuom@4ax.com>
Kiralynne Schilitubi wrote:
>> Not true. "strict" ONLY has an effect on the parsing of the program.
>> Once compiled, the program will run exactly just as fastwith as without
>> "strict". As for crashing, the same applies: the compiled code is
>> exactly the same, so there's not one single reason on why it should
>> crash more often.
>
>This is untrue. My tests show a significant average 1.64 percent slow
>down of a script using a very simple code snippet.
My applologies. There is at least ONE area where "strict" has a runtime
effect: it makes sure you don't use a string as a reference (symbolic
references). I would think that you'd only see a slowdown, if any, if
you are indeed using references. But since symbolic references need to
be treated differently anyway, than real references, I can't see how
this can affect the ordinary case, because the script needs to test for
it in any case. There only difference should occur IF you're using
symbolic references.
>Much worse. Use of strict causes pragma hints to report false
>and misleading error messages. This is what happens with strict
>in use for my example snippet below my signature, when lacking
>a correct my declaration,
>
>Global symbol "$ilabika" requires explicit package name at... line 7.
>Global symbol "$ilabika" requires explicit package name at... line 12.
>Global symbol "$ilabika" requires explicit package name at... line 14.
>Execution of test4.pl aborted due to compilation errors
>
>Pragma warning indicates a total of three errors on various
>lines. Reality dictates $ilabika only needs to be a my declaration
>on line 7, to correct this error, when using strict.
It only says that it finds an undeclared name. It did find this name,
repeatedly, on these lines.
But I do agree that "strict" can throw confusing and irrelevant error
messages, especially if you have a brace (block marker) mismatch. I feel
that there should be (at least) two levels of error messages, with
"declaration" complaints only on the second level. You should only see
those, if there is no other, serious error in your script.
Implementation could be done by putting strict's complaints into a
buffer, which only gets to be printed (to STDERR) when the script is
completely compiled succesfully.
Traditional language compilers often do this by treating variable names
as a semantic check, in a second pass, not a compilation check at the
first pass. But not Perl.
--
Bart.
------------------------------
Date: 26 Feb 2001 22:34:13 +0000
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: Re: Please Help with 10 line programm -- beginner questions
Message-Id: <m3u25hhy56.fsf@yarn.demon.co.uk>
"mshort" <mshort@usol.com> writes:
If you change the comma in the while condition to && it works.
> The assignment in the book is to modify this program:
>
>
> print 'Would you like to see the 11:00 show of Cape Fear?';
> chomp($ans=<>);
> if ($ans eq 'yes'){
> print "that'll be 8.50\n";
> } elsif ($ans eq 'no'){
> print "Okay\n";
> } else {print "please try again\n";
> }
>
> With a WHILE loop.
>
> I have tried several variations and this is the best one I come up with, but
> it has a problem:
>
> while ($ans ne 'yes', $ans ne 'no'){
> print 'Would you like to see the 11 show of Cape Fear?';
> chomp($ans=<>);
> if ($ans eq 'yes'){
> print "that'll be 8.50\n";
> } elsif ($ans eq 'no'){
> print "Okay\n";
> } else {
> print "please try again\n";
> }
> }
>
> It won't exit upon $ans eq 'yes'. I am figuring in the condition of the
> WHILE statement is where my problem lies. I know there must be a way for
> WHILE to loop if $ans is not equal to yes AND no. And I think I can use 2
> while loops one for each yes and no, but I am hoping there is a more
> efficient way.
>
>
> Sincerely,
>
> Matt Short
>
>
>
--
Paul
http://www.seditiousdiaries.com/Donald15.html
------------------------------
Date: Tue, 27 Feb 2001 05:35:34 GMT
From: Alexandra <lanaS55nospam@hotmail.com>
Subject: Re: receiving piped input???
Message-Id: <3A9AD99B.30543D8F@hotmail.com>
Anno Siegel wrote:
> According to Alexandra <lanaS55nospam@hotmail.com>:
> > Consider this simple shell script:
> >
> > #!/bin/sh
> > myprogram | perl myperlscript
> >
> > How do I read the output from myprogram inside of myperlscript???
>
> From STDIN.
>
> Anno
I know that the pipe takes the stdout from "myprogram" and pipes it in
to the stdin of the perl script. How could I not know that to get it I
need to read the stdin. A child could have figured this out. I feel
stupid.
Scott
------------------------------
Date: Tue, 27 Feb 2001 03:45:48 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Script Problems - Please Help
Message-Id: <CABFEF7878F2FB0D.EF996A44B8539519.591DF8F8108B0F1A@lp.airnews.net>
"Mick Beeby" <mick.beeby@mjb-is.co.uk> wrote:
: I have a Perl script which does whois lookup on multiple TLD's. The
problem
: I have is two fold:-
:
: 1) If I name the script with a .pl extension it returns correct
information
: regarding whether particular domains are available or not but I sometimes
: get error messages such as 'Use of uninitialized value in transliteration
: (tr///) at f:\mjb-is\mjb-is\cgi-bin\whois.pl line 109. ' and 'Use of
: uninitialized value in pattern match (m//) at
: f:\mjb-is\mjb-is\cgi-bin\whois.pl line 278.' etc. I get several of the
: latter ones. I also get this 'The name specified is not recognized as an
: internal or external command, operable program or batch file.' The results
: do get printed to the screen and are coreect though.
:
: 2) If I name the script with a .cgi extension it works fine without any
: errors but returns false information. i.e. all domain are listed as
: available even when I know which ones are not.
:
: What are the consequences of using a differnet extension? The scripts are
in
: the cgi-bin directory. This is getting really annoying as sometimes the
.pl
: one works fine without generating the error messages. If you submit a
second
: time it usually is OK.
:
: I would appreciate any tips on this. I am not really a Perl programmer at
: heart or though I canpick my way round thigs and work stuff out. I have
more
: experience with Javascript, VBScript, ASP etc.
:
Check with your sysadmin. It is possible to run programs and set
variables when certain files are requested. That is only one
possible explanation for a difference between a .pl and a .cgi script.
As Bob mentions in another thread, you'll have to post some code
for help with specific problems. For the line 109 error, try posting
relevant code from lines 100 - 120.
Don't include the line numbers, but do point out which is the
offending line. If 109 is in a sub, include the whole sub and give us
an idea what the inputs are. We'll let you know if you didn't post
enough info.
HTH,
Charles K. Clarkson
------------------------------
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 V10 Issue 363
**************************************