[17834] in Perl-Users-Digest
Perl-Users Digest, Issue: 5254 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 5 03:06:01 2001
Date: Fri, 5 Jan 2001 00:05:35 -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: <978681934-v9-i5254@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 5 Jan 2001 Volume: 9 Number: 5254
Today's topics:
Re: $ENV{'QUERY_STRING'} Question (Martien Verbruggen)
Re: %ENV does not contain some variables? <bart.lateur@skynet.be>
Re: %ENV does not contain some variables? <nospam@nospam.com>
Re: '/usr/sbin/sendmail' <peter.sundstrom@eds.com>
-M <test31@docuharbor.com>
Re: -M <rrocky@bigfoot.com>
Re: -M <stampes@xilinx.com>
Re: -M (Martien Verbruggen)
[Q] matching many regular expressions [..] <ian.trudel@tr.cgocable.ca>
Re: Any good Perl books? <nospam@nospam.com>
Re: Any good Perl books? (Damian James)
anyone know how to simulate a mouse click? <msellers@jup.com>
Re: anyone know how to simulate a mouse click? <mustbe@pdelahunta.cjb.com>
Re: anyone know how to simulate a mouse click? <mischief@velma.motion.net>
Re: anyone know how to simulate a mouse click? <msellers@jup.com>
Re: anyone know how to simulate a mouse click? (Tad McClellan)
Re: anyone know how to simulate a mouse click? <gisle@ActiveState.com>
beginner question <heidi@nospamtreesforlife.org>
Re: beginner question <nosp@m.please>
Re: beginner question <mischief@velma.motion.net>
Re: beginner question <ren.maddox@tivoli.com>
Re: beginner question (Abigail)
Re: beginner question <stampes@xilinx.com>
RE: Bug with Apache::TicketMaster, TicketAccess gary@ashton-jones.com.au
cgi script timeout romper24_7@my-deja.com
Re: command execution timeout gls@byu.edu
displaying a gif from a cgi... tohann@my-deja.com
Re: displaying a gif from a cgi... (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 5 Jan 2001 12:10:22 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn95a7nu.edk.mgjv@martien.heliotrope.home>
On 4 Jan 2001 10:42:15 GMT,
Ilmari Karonen <iltzu@sci.invalid> wrote:
> In article <slrn9578vm.edk.mgjv@martien.heliotrope.home>, Martien
> Verbruggen wrote:
>>On 3 Jan 2001 13:09:59 GMT,
>> Ilmari Karonen <iltzu@sci.invalid> wrote:
>>>
>>> $q =~ s/[^ \w]/sprintf '%%%02X', ord $&/eg;
>>> $q =~ tr/ /+/;
>>
>>Because the way you use it isn't the way the OP wanted to use it. If you
>>follow the link provided by the OP you'll find that where he wanted to
>>use the code he's talking about (and he needs unescape, not escape) is
>
> Okay, then reverse it.
>
> $query =~ tr/+/ /;
> $query =~ s/%([\dA-F][\dA-F])/chr hex $1/ieg;
>
>
>>that won't change in the future. Even in the example of your script,
>>invalid characters may be left in the query string, even though maybe
>>lynx doesn't care or even escapes them for you.
>
> Ehm? Which character in \w is invalid in an URL?
That's not the point. The point is that any escape sequence is allowed
to be used in a query string, regardless of whether it's reserved or
not. If I decide to escape the hypen, or _, or ~, then your CGI program
_should_ correctly deal with it. if you only implement partial decoding,
then you won't do everything correctly.
And please note that the stuff you have above is substantially different
from the original solution I commented on. Of course, if we keep going
like this for a few posts, we'll have a complete solution. probably one
which is fairly identical to the code in one of the modules. However,
the fact remains that that solution didn't just automagically pop up,
but needed iterations.
The modules have had these iterations.
The point is simply that there is a lot more to it than unescaping one
or two characters, or even a whole swag of them. If you don't _know_ all
of the possibilities, you should use a module, instead of partially
implementing stuff.
Martien
--
Martien Verbruggen |
Interactive Media Division | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd. | but mean your mother.
NSW, Australia |
------------------------------
Date: Thu, 04 Jan 2001 20:59:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: %ENV does not contain some variables?
Message-Id: <sto95tokluo3k8pgucba713a4ib80esmrc@4ax.com>
Dave Brondsema wrote:
>The server has perl 5.006 installed, using Microsoft-IIS/4.0
Ah, yes. In my experience, Perl's %ENV under IIS behaves that way. For
most of the %ENV (CGI related -- but only those???) entries, it isn't
there (yet), until you actively access it. I'm not sure it's perl's
internals, or IIS, that makes it act like that.
--
Bart.
------------------------------
Date: 4 Jan 2001 23:30:43 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: %ENV does not contain some variables?
Message-Id: <933133$ncl$0@216.155.32.178>
In article <978605000.25617@itz.pp.sci.fi>, Ilmari Karonen
<usenet11326@itz.pp.sci.fi> wrote:
| >You lost me about the 'escaping' problem -- As near as I can tell,
| >there's no info that needed to be escaped anywhere in that as both
| >scripts validated perfectly.
|
| Well, there were really two problems. One was the use of ||, which
| would consider the value "0" false and replace it with "Not Defined".
|
| The second problem was the lack of escapeHTML(), causing the code to
| let any < or & characters in the values through as is.
|
| Obviously, both would only happen for some ENV values, so testing the
| script with other values won't help in noticing the bug.
ok.. makes sense. Thanks for the heads-up... I'll remember that in the
future.
| >Both scripts produced 100% accurate and validatable "HTML 4.01
| >Transitional" code, so I'm not 100% sure why you made the change to the
| >subroutine usage and used an array instead.
|
| Oh, that. That was just personal preference. Should work either way.
okay. Thanks :)
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Fri, 5 Jan 2001 10:19:45 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: '/usr/sbin/sendmail'
Message-Id: <932pdi$vcp$1@hermes.nz.eds.com>
Michel <mkupfer@hotmail.com> wrote in message
news:931q4b$768$1@news1.sunrise.ch...
> Hello,
>
> I have a script in CGI with : '/usr/sbin/sendmail'
> I want use it with Windows NT and the fonction is 'blat.exe'
blat does not the same functionality as sendmail. One is a MUA the other is
a MTA.
Go to http://search.cpan.org/ and use one of the many mail modules that will
work under Unix and NT
------------------------------
Date: Thu, 04 Jan 2001 17:09:35 -0600
From: Todd Anderson <test31@docuharbor.com>
Subject: -M
Message-Id: <3A54FE5C.164929D8@docuharbor.com>
Anyone know what this does? (specifically the -M and the .1)
Thanks in advance.
if (-M "$directory/$me" > .1)
{
unlink("$directory/$me");
}
------------------------------
Date: Thu, 04 Jan 2001 15:47:59 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: -M
Message-Id: <3A550BAF.26047E33@bigfoot.com>
Todd Anderson wrote:
>
> Anyone know what this does? (specifically the -M and the .1)
> Thanks in advance.
>
> if (-M "$directory/$me" > .1)
> {
> unlink("$directory/$me");
> }
-M gives age of file in days since modification.
So .1 probably means 2.5 hrs or so.
--
Rocky
RSC - http://www.slack.net/~shiva/rsc.html
------------------------------
Date: Thu, 04 Jan 2001 16:52:27 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: -M
Message-Id: <3A550CBB.5134B1ED@xilinx.com>
Todd Anderson wrote:
> Anyone know what this does? (specifically the -M and the .1)
> Thanks in advance.
>
> if (-M "$directory/$me" > .1)
> {
> unlink("$directory/$me");
> }
perldoc -f -M will tell you that -M returns the age of file in days
when script started.
.1 in this context is the same as 2.4 hours or 144 minutes
So this will remove "$directory/$me" if it has not been modified in 144
minutes.
------------------------------
Date: Fri, 5 Jan 2001 12:24:30 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: -M
Message-Id: <slrn95a8ie.edk.mgjv@martien.heliotrope.home>
On Thu, 04 Jan 2001 17:09:35 -0600,
Todd Anderson <test31@docuharbor.com> wrote:
> Anyone know what this does? (specifically the -M and the .1)
>
>
> if (-M "$directory/$me" > .1)
> {
> unlink("$directory/$me");
> }
The perlfunc documentation talks about -M, the perldata documentation
about all the numerical constants perl will accept. you'll find that .1
is simply the same as 0.1. If you read perlfunc, which I hope you will
now do, you'll find that the statement above says something like 'if the
file $directory/$me is older than 0.1 of a day...'
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Fri, 05 Jan 2001 07:33:29 GMT
From: "Ian Trudel" <ian.trudel@tr.cgocable.ca>
Subject: [Q] matching many regular expressions [..]
Message-Id: <dNe56.798$Br2.121241@carnaval.risq.qc.ca>
Hello,
I'm willing to match many regular expressions at once, see reference [1].
However, I would like to do so _with constrains_. For example (simple one),
if I want to match two pair of numbers, separated by a coma and that has two
digits, and each has a constrains. The first one has, let's say, to be
between 0 and 40 and the second has to be between 41 and 50. I'd like to be
able to work as following (or similarly):
$result = manyReg{
/([0-9]{2})/ && ($1 <= 40),
/([0-9]{2})/ && ($1 > 40 && $1 <= 50)
};
Anything builtin? Any hint?
Regards,
Ian
[1]
http://www.perl.com/pub/doc/manual/html/pod/perlfaq6.html#How_do_I_efficient
ly_match_many_
--
----------------------------------------------------------------
*squeak* *squeak* said the little mouse while eating a java hog.
Ian Trudel, mailto:ian.trudel@tr.cgocable.ca
------------------------------
Date: 5 Jan 2001 00:53:19 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Any good Perl books?
Message-Id: <9335tv$396$1@216.155.32.178>
In article <slrn9593ia.qdu.abigail@tsathoggua.rlyeh.net>,
abigail@foad.org wrote:
| Bad ones: Learning Perl
| Advanced Perl Programming
what's bad about APP ? outdated? I'd been considering getting this one,
and would like to hear a little about why it wouldn't be a good choice.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 5 Jan 2001 02:13:48 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Any good Perl books?
Message-Id: <slrn95abh9.8ag.damian@puma.qimr.edu.au>
In article <slrn9593ia.qdu.abigail@tsathoggua.rlyeh.net>, Abigail wrote:
>
>Bad ones: ...
> Advanced Perl Programming
> Mastering Algorithms with Perl
>
Just out of interest, I was wondering what your problem with
these two might be.
I think I can guess -- is it because they might lead the novice
programmer to the conclusion that s/he needn't go and read standard
the Comp Sci texts on similar subjects?
I have been reading the latter book recently, and found it enlightening
within bounds (but would hate to think it is teaching me _bad_ things).
Cheers,
Damian
------------------------------
Date: Thu, 04 Jan 2001 15:00:05 -0500
From: Matt Sellers <msellers@jup.com>
Subject: anyone know how to simulate a mouse click?
Message-Id: <3A54D645.DAD778DE@jup.com>
Hello,
Does anyone know of a way to simulate a mouse click with a perl
program, for instance a script that, once run, connects to
http://www.mypage.com/
and clicks at x=340 y=190 ? Any help would be appreciated.
------------------------------
Date: Thu, 04 Jan 2001 21:53:52 +0100
From: Paul <mustbe@pdelahunta.cjb.com>
Subject: Re: anyone know how to simulate a mouse click?
Message-Id: <3A54E2DF.6DD94D0@pdelahunta.cjb.com>
Matt Sellers wrote:
> Hello,
>
> Does anyone know of a way to simulate a mouse click with a perl
> program, for instance a script that, once run, connects to
> http://www.mypage.com/
> and clicks at x=340 y=190 ? Any help would be appreciated.
Maybe you can be somewhat more specific?
Paul
------------------------------
Date: Thu, 04 Jan 2001 21:05:22 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: anyone know how to simulate a mouse click?
Message-Id: <t59pcinn6cr832@corp.supernews.com>
Matt Sellers <msellers@jup.com> wrote:
> Hello,
> Does anyone know of a way to simulate a mouse click with a perl
> program, for instance a script that, once run, connects to
> http://www.mypage.com/
> and clicks at x=340 y=190 ? Any help would be appreciated.
You don't really want the program to simulate a mouse click.
What you want is for the program to act as a client, and for
it to do what a browser would do to tell the server where a
mouse click was supposedly made. There are two types of image
maps.
The best place to look for HTML specs is http://www.w3.org
which is the home page of the Worled Wide Web Consortium, or
W3C for short.
This really is not a Perl issue, it is an HTML client issue.
Read the HTML specs. I'll go ahead and include part of the
HTML 4.01 spec concerning image maps if you promise to read
the rest yourself.
An image map is created by associating an object with a specification of sensitive geometric areas on the object.
<part of the image map spec>
There are two types of image maps:
Client-side.
When a user activates a region of a client-side image map
with a mouse, the pixel coordinates are interpreted by the
user agent. The user agent selects a link that was specified
for the activated region and follows it.
Server-side.
When a user activates a region of a server-side image map
with a mouse, the pixel coordinates of the click are sent
to the server-side agent specified by the href attribute
of the A element. The server-side agent interprets the
coordinates and performs some action.
Client-side image maps are preferred over server-side image
maps for at least two reasons: they are accessible to people
browsing with non-graphical user agents and they offer
immediate feedback as to whether or not the pointer is over
an active region.
</part of the image map spec>
The above and much more can be found at:
http://www.w3.org/TR/html4/struct/objects.html#h-13.6
Please go to a web-related newsgroup with further questions.
Chris
--
Christopher E. Stith
Product shown enlarged to make you think you're getting more.
------------------------------
Date: Thu, 04 Jan 2001 16:16:56 -0500
From: Matt Sellers <msellers@jup.com>
Subject: Re: anyone know how to simulate a mouse click?
Message-Id: <3A54E848.7AACB5BF@jup.com>
Ok, let's say I write something like this:
#!/usr/bin/perl -w
use strict;
use LWP::Simple qw(get);
my $url = "http://www.foo.com/";
my $page = get $url or die "hi: $!\n";
print "Content-type: text/html\n\n";
print "$page";
let's assume this page has a submit button. Can I simulate a mouse click so
that the button is pushed, thus sending info to the cgi script that handles
the form input?
Alternatively, if the above is not possible, can I connect to a web site
via a socket and have some predefined areas to click, such that I could run
the script and make it through an entire set of forms? A statement like: my
$next_page = get->Mouse::Click(480, 135) would be one example, which would
allow $next_page to contain the html yielded from the page after clicking the
submit button.
Any help would be appreciated.
Paul wrote:
> Matt Sellers wrote:
>
> > Hello,
> >
> > Does anyone know of a way to simulate a mouse click with a perl
> > program, for instance a script that, once run, connects to
> > http://www.mypage.com/
> > and clicks at x=340 y=190 ? Any help would be appreciated.
>
> Maybe you can be somewhat more specific?
> Paul
------------------------------
Date: Thu, 4 Jan 2001 19:42:29 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: anyone know how to simulate a mouse click?
Message-Id: <slrn95a63l.nv0.tadmc@magna.metronet.com>
[ Please put your comments *following* the quoted text that you
are commenting on.
Please do not quote an entire article.
Jeopardectomy performed.
]
Matt Sellers <msellers@jup.com> wrote:
>Paul wrote:
>> Matt Sellers wrote:
>>
>> > Does anyone know of a way to simulate a mouse click with a perl
>> > program,
You can do GUI stuff with the Tk module.
>for instance a script that, once run, connects to
>> > http://www.mypage.com/
>> > and clicks at x=340 y=190 ? Any help would be appreciated.
Oh. You don't mean just a Perl program, you mean a Perl program
running in a CGI environment. Not at all the same thing.
>> Maybe you can be somewhat more specific?
>Ok, let's say I write something like this:
[ snip very fine code with warnings and strictures ]
>let's assume this page has a submit button.
So then it has a <form> tag. Examine it to see what it does.
What HTML thingies mean is off-topic in a Perl newsgroup.
>Can I simulate a mouse click so
>that the button is pushed, thus sending info to the cgi script that handles
>the form input?
Oh, I see now what you want.
No. What you do is write a Perl program that does what the browser
does when you "click" (so that you don't have to click).
When you click on "submit" something happens. What the something
is is specific to the application area that you are applying
Perl to, not to Perl.
So it should not be here in the Perl newsgroup. Luckily there
is a newsgroup where such things are discussed:
comp.infosystems.www.authoring.cgi
Find out what the interface requires, then code it up in Perl.
>Any help would be appreciated.
use LWP::UserAgent; # to submit a "filled out" form
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 05 Jan 2001 04:56:32 GMT
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: anyone know how to simulate a mouse click?
Message-Id: <m3vgruvbo3.fsf@ActiveState.com>
Matt Sellers <msellers@jup.com> writes:
> Ok, let's say I write something like this:
>
> #!/usr/bin/perl -w
> use strict;
> use LWP::Simple qw(get);
> my $url = "http://www.foo.com/";
> my $page = get $url or die "hi: $!\n";
> print "Content-type: text/html\n\n";
> print "$page";
> let's assume this page has a submit button. Can I simulate a mouse click so
> that the button is pushed, thus sending info to the cgi script that handles
> the form input?
I think that the HTML::Form module should do what you like. Just try
to append lines like the following to your script:
require HTML::Form;
my $form = HTML::Form->parse($page, $url);
my $req = $form->click(480, 135);
# $req is a HTTP::Request object, so you have to use OO LWP after this
$ua = LWP::UserAgent->new;
my $res = $ua->request($req);
print $res->as_string;
--
Gisle Aas
------------------------------
Date: Thu, 04 Jan 2001 22:41:18 GMT
From: "hmm" <heidi@nospamtreesforlife.org>
Subject: beginner question
Message-Id: <i_656.33218$zh.3838367@typhoon.kc.rr.com>
I am reading from a text file. The first line is always empty and my
contents get written from line 2 on. When I read that text file, how do I
get my code to skip the blank line and write the remaining contents?
open (OUTPUT,"< cgi-bin/step3file.txt") or print "Error opening file
step3file.txt\n";
while ($line=<OUTPUT>){
print "<table align='center' width='400'>";
if($line eq ???????){ # I don't know what to type here
next;
}else{
print "Summary item ";
print ++$i;
print $line;
print "<br>";
}
}
close OUTPUT;
thanks in advance.
------------------------------
Date: Thu, 04 Jan 2001 23:56:45 +0100
From: DrC <nosp@m.please>
Subject: Re: beginner question
Message-Id: <3A54FFAD.9600B6@m.please>
hmm wrote:
>
> I am reading from a text file. The first line is always empty and my
> contents get written from line 2 on. When I read that text file, how do I
> get my code to skip the blank line and write the remaining contents?
>
> open (OUTPUT,"< cgi-bin/step3file.txt") or print "Error opening file
> step3file.txt\n";
> while ($line=<OUTPUT>){
> print "<table align='center' width='400'>";
chomp( $line );
if($line eq "" ){
> next;
> }else{
> print "Summary item ";
> print ++$i;
> print $line;
> print "<br>";
> }
> }
> close OUTPUT;
>
> thanks in advance.
------------------------------
Date: Thu, 04 Jan 2001 23:17:09 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: beginner question
Message-Id: <t5a13l205js2d5@corp.supernews.com>
hmm <heidi@nospamtreesforlife.org> wrote:
> I am reading from a text file. The first line is always empty and my
> contents get written from line 2 on. When I read that text file, how do I
> get my code to skip the blank line and write the remaining contents?
By testing to see if it's an empty line?
> open (OUTPUT,"< cgi-bin/step3file.txt") or print "Error opening file
> step3file.txt\n";
Your program should die() here, of try to recover.
> while ($line=<OUTPUT>){
This does the same as
while(<OUTPUT>) {
except your variable is not used, and $_ is instead.
You can fix that this way, if you really need it to be called
$line...
while(<OUTPUT>) {
$line = $_;
which is more idiomatic.
> print "<table align='center' width='400'>";
> if($line eq ???????){ # I don't know what to type here
chomp($line);
if($line eq '') {
The line being empty after getting rid of the newline would
be an empty string, yes?
> next;
next() in this case is superfluous. You're not doing anything
else in the loop after this point. It might be handy to remind
yourself what you mean to do, and might save you errors if you
add stuff after the if statement later.
> }else{
> print "Summary item ";
> print ++$i;
> print $line;
> print "<br>";
> }
> }
> close OUTPUT;
Here's your code adjusted for my eyes:
<modified code>
open(OUTPUT, "<cgi-bin/stepfile3.txt") || die "Can't open file: $!\n";
while(<OUTPUT>) {
if( /^$/ ) { ### uses a simple regex match checking to see
### if there's nothing between start and end
} else {
$i++;
print "Summary item $i $_<br>";
}
}
</modified code>
Remember, though, that it's customary to put the HTML break
at the end of a line, not the beginning as your code (and
therefore mine too) does. It won't matter to a browser or
to the HTML spec police, but someone maintaining the code
by hand can sometimes be picky.
> thanks in advance.
YW.
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: 04 Jan 2001 17:01:39 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: beginner question
Message-Id: <m3elyi6hws.fsf@dhcp11-177.support.tivoli.com>
"hmm" <heidi@nospamtreesforlife.org> writes:
> I am reading from a text file. The first line is always empty and my
> contents get written from line 2 on. When I read that text file, how do I
> get my code to skip the blank line and write the remaining contents?
If you just want to skip the first line no matter what, simply read a
line before the loop starts and discard it:
> open (OUTPUT,"< cgi-bin/step3file.txt") or print "Error opening file
> step3file.txt\n";
<OUTPUT>; # skip the first line
> while ($line=<OUTPUT>){
If instead you want to skip any blank lines, use one of:
next if $line =~ /^$/; # skip truly blank lines
next if $line =~ /^\s*$/; # skip lines with nothing but whitespace
> print "<table align='center' width='400'>";
> if($line eq ???????){ # I don't know what to type here
Well, if you really want to do it this way you can, then depending on
whether you want to always skip the first line, only skip the first
line if it's blank, or skip all blank lines, you could use one of:
if ($. == 1) {
if ($. == 1 && $line =~ /^$/) {
if ($line =~ /^$/) {
[rest of code omitted]
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 5 Jan 2001 00:46:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: beginner question
Message-Id: <slrn95a6bg.9sh.abigail@tsathoggua.rlyeh.net>
Chris Stith (mischief@velma.motion.net) wrote on MMDCLXXXIII September
MCMXCIII in <URL:news:t5a13l205js2d5@corp.supernews.com>:
}}
}} Here's your code adjusted for my eyes:
}}
}} <modified code>
}} open(OUTPUT, "<cgi-bin/stepfile3.txt") || die "Can't open file: $!\n";
}} while(<OUTPUT>) {
}} if( /^$/ ) { ### uses a simple regex match checking to see
}} ### if there's nothing between start and end
}} } else {
}} $i++;
}} print "Summary item $i $_<br>";
}} }
}} }
}} </modified code>
Of course, if you really want to only skip the first line, putting
a test for that inside the loop is an utter waste of CPU cycles.
And it creates bad programming habits. Programming 101 tells you
to take everything out of a loop that doesn't need to be there.
Light loops are the way to go.
open my $input => "cgi-bin/stepfile3.txt" or
die "Failed to open file: $!\n";
<$input>; # Skips first line.
my $i = 0;
while (<$input>) {
printf "Summary item %d %s<br>" => ++ $i, $_;
}
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
------------------------------
Date: Thu, 04 Jan 2001 17:05:48 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: beginner question
Message-Id: <3A550FDC.4A239D07@xilinx.com>
Chris Stith wrote:
> hmm <heidi@nospamtreesforlife.org> wrote:
> > while ($line=<OUTPUT>){
>
> This does the same as
>
> while(<OUTPUT>) {
>
> except your variable is not used, and $_ is instead.
> You can fix that this way, if you really need it to be called
> $line...
>
> while(<OUTPUT>) {
> $line = $_;
>
> which is more idiomatic.
And potentially more problematic. There's nothing inherently wrong with using
$_ in the correct places (and this is actually one of those places). But
there's also nothing inherently wrong with the OP's version. In fact, I find
myself avoiding use of $_ as often as possible. Too many modules/functions
step on it, leaving you chasing down bizarre failures.
My rule of thumb: Use $_ if you know exactly what you're doing, but if you
find bizarre problems in it's neighborhood, immediately rename it. And
certainly don't discourage use of alternate variables.
-Jeff
------------------------------
Date: Fri, 05 Jan 2001 06:58:49 GMT
From: gary@ashton-jones.com.au
Subject: RE: Bug with Apache::TicketMaster, TicketAccess
Message-Id: <933rb8$t46$1@nnrp1.deja.com>
After much frustration with the TicketMaster example not working I
asked for help and got this:
Extract from email received from Doug MacEachern 5 Jan 01:
"try the Apache::AuthTicket that's on cpan. it is based on the book
example and includes several enhancements. Apache::AuthCookie, also on
cpan, might be of interest. the book example that is in the modperl.com
source tarball worked the last time i tried, but you're better off going
with a supported release on cpan."
HTH
Gary Ashton-Jones
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 04:11:23 GMT
From: romper24_7@my-deja.com
Subject: cgi script timeout
Message-Id: <933hh6$lps$1@nnrp1.deja.com>
Hi. I am building a web interface to prolog but
have one unfortunate problem. It is quite easy to
put prolog into an infinite loop which "hangs" the
cgi script until the server decides a timeout is
necessary. Is there anyway to set a timeout for
the script from within the script itself?
(Also, if CGI::MiniSvr is a solution, could
someone give some advice into its use/caveats)
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 04 Jan 2001 10:58:50 -0700
From: gls@byu.edu
Subject: Re: command execution timeout
Message-Id: <uk88b2o85.fsf@SNOW.i-did-not-set--mail-host-address--so-shoot-me>
rbfitzpa@my-deja.com writes:
> I'm trying to use a command to test if my application is up and running.
> The problem is that if my application is down my command does not
> respond - it hangs.
>
> Q: Is there a way to execute a commandline command in perl but have perl
> 'time out' that command?
You might want to check out the Expect module on CPAN.
Unless you need it for windows, I don't think that it
has been ported there yet.
------------------------------
Date: Fri, 05 Jan 2001 05:15:57 GMT
From: tohann@my-deja.com
Subject: displaying a gif from a cgi...
Message-Id: <933laa$osh$1@nnrp1.deja.com>
Hello. I'm trying to display a gif image returned from a cgi program to
an <IMG SRC=... tag. I can display an image from my own server just
fine, but when I try to display an image from another server, it doesn't
show. Is there some slick way to do this? Here's the code I'm using...
The HTML that calls the cgi:
<IMG SRC="http://www.myserver.com/cgi-bin/banners.cgi?action=banner">
and the portion of the cgi that displays the image:
#
open(GIF, $bannerFileName)
or die("OPEN FAILED: $! => $bannerFileName");
#
binmode GIF;
#
undef $/;
my $image = <GIF>;
#
close GIF;
#
print $query->header(-type=>"image/gif"), $image;
Like I said, $bannerFileName will either point to a gif on my server, or
one offsite. I'm relatively new to the cgi processing, and I'm
guessing that that's my problem. I can't treat gifs on my server and
offsite gifs as the same.
Any ideas on how I could fix this to show the offsite gifs, or a
direction to look to get the answer?
Thanks,
Trent O.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 5 Jan 2001 06:41:30 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: displaying a gif from a cgi...
Message-Id: <933qaq$llt$1@bob.news.rcn.net>
tohann@my-deja.com wrote:
> Hello. I'm trying to display a gif image returned from a cgi program to
> an <IMG SRC=... tag. I can display an image from my own server just
> fine, but when I try to display an image from another server, it doesn't
> show. Is there some slick way to do this? Here's the code I'm using...
> The HTML that calls the cgi:
> <IMG SRC="http://www.myserver.com/cgi-bin/banners.cgi?action=banner">
> and the portion of the cgi that displays the image:
> #
> open(GIF, $bannerFileName)
> or die("OPEN FAILED: $! => $bannerFileName");
> #
> binmode GIF;
> #
> undef $/;
> my $image = <GIF>;
> #
> close GIF;
> #
> print $query->header(-type=>"image/gif"), $image;
> Like I said, $bannerFileName will either point to a gif on my server, or
> one offsite. I'm relatively new to the cgi processing, and I'm
> guessing that that's my problem. I can't treat gifs on my server and
> offsite gifs as the same.
Your problem is that you've forgotten that URLs are not file names and
that Perl's file IO works only with actual *files*. To fetch the contents
of a file on a remote system addressed by a URL, you'll have to (OK, not
*have* to, but this is the easiest way) use the LWP module. If you don't
already have it installed, install it. Then read its documentation.
You'll probably be able to use LWP::Simple for the task.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5254
**************************************