[15476] in Perl-Users-Digest
Perl-Users Digest, Issue: 2886 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 28 00:10:24 2000
Date: Thu, 27 Apr 2000 21:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956895013-v9-i2886@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 27 Apr 2000 Volume: 9 Number: 2886
Today's topics:
perl in NT .BAT files Question <DNess@Home.Com>
PerlScript error with IIS or Win2000 <aahz@gol.com>
Re: PerlScript error with IIS or Win2000 <ronnie@catlover.com>
Re: PerlScript error with IIS or Win2000 <aahz@gol.com>
Printing integers from array <gbsadler1@sprynet.com>
Re: Printing integers from array <caraudio@streetdreams.com>
Re: Printing integers from array <gbsadler1@sprynet.com>
Re: Printing integers from array <aperrin@davis.DEMOG.Berkeley.EDU>
Re: Printing integers from array <gbsadler1@sprynet.com>
Re: Printing integers from array <lauren_smith13@hotmail.com>
Testing for require/use vs. execution? <brian@bluecoat93.org>
Thread programming <jammerie@hotmail.com>
use overload; - interface stable? (Lee)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Apr 2000 02:17:48 GMT
From: David Ness <DNess@Home.Com>
Subject: perl in NT .BAT files Question
Message-Id: <3908F4D3.4FBC31E5@Home.Com>
I have successfully used, but without completely understanding, a
Windows/perl `pun' under NT which allows a single file to contain both the OS
commands to execute perl and the perl code itself. I don't remember the source
of this pun, but it has been a part of lots of my perl work for the last
couple of years, and some help about the use of '-w' and `strict'
now cause me to want to see if there is a better way to do things
with respect to this fragment.
I believe the code relies on a pun which lets the first line of the file
mean different things to the windows .BAT processor and to perl. Windows
can execute the beginning of the file and then skip the perl content while
the perl processor skips the .BAT (Windows) part and sees only the perl content.
Thus I guess it allows a sort of logical equivalent of Unix's `#!', in that
it makes an `executable' which can conveniently mix Windows work with
perl.
The fragment looks like this:
@REM='<$MyName Demonstration File - Ver DN-1A(2) - [BKX-LUSZ]$>
@Echo Off
perl %PerlFlag% %BIN%\MyName.BAT %*
GoTo EndPerl
@REM=';
...
#Body of perl program appears here
...
__END__
:EndPerl
AFAICS the .BAT processor sees @REM as a remark and then (eventually)
does a `GoTo' around the perl code, while perl sees the file as an
assignment of a long quoted string to `@REM' followed by normal perl
which terminates, logically at the `__END__'.
This has worked fine for a long time, but now that I am processing my
files with a `-w' I get a `used only once' on `@REM'. I can't use the
my() structure to avoid this because, while it works well other places,
here the `@REM' has to be the first thing encountered. I find I can
avoid the diagnostic by including a `@REM=@REM;' as the first line
of executable perl code, but I don't know if that is good practice or if
there is some better way.
Alternatively, is there some better way to handle this whole problem in
Windows/perl?
------------------------------
Date: Thu, 27 Apr 2000 23:09:23 GMT
From: "Chris Williams" <aahz@gol.com>
Subject: PerlScript error with IIS or Win2000
Message-Id: <DM3O4.1151$uL2.90583@nnrp.gol.com>
I am trying to get PerlScript running on my computer, but the errors it is
giving me would seem to negate the possibility of ever accomplishing
anything. For just the following:
<%@ language = PerlScript %>
<html><title>Hello</title><body><h1>Hello</h1></body></html>
I receive the following in IE5:
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did not return are:
syntax error at c:\inetpub\wwwroot\Test\Test.pl line 2, near ""
Bareword found where operator expected at c:\inetpub\wwwroot\Test\Test.pl
line2, near "/title>
Hello
The final "Hello" being my h1. If anyone has any comments or suggestions
for things to try, please don't hesitate to offer them.
------------------------------
Date: Fri, 28 Apr 2000 02:19:29 GMT
From: Ron Grabowski <ronnie@catlover.com>
Subject: Re: PerlScript error with IIS or Win2000
Message-Id: <3908F566.70B61543@catlover.com>
> syntax error at c:\inetpub\wwwroot\Test\Test.pl line 2, near ""
Odds are your script is being sent to Perl.exe as a CGI script rather
than being interpreted by Perscript. Try changing the name of your file
to test.asp and see what happens.
<%@ LANGUAGE = PerlScript %>
<HTML>
<BODY>
<H1>Hello World</H1>
<% $Response->Write("Hello!"); %>
</BODY>
</HTML>
------------------------------
Date: Fri, 28 Apr 2000 04:02:02 GMT
From: "Chris Williams" <aahz@gol.com>
Subject: Re: PerlScript error with IIS or Win2000
Message-Id: <_28O4.1152$uL2.90584@nnrp.gol.com>
It doesn't load. IE5 just sits there.
"Ron Grabowski" <ronnie@catlover.com> wrote in message
news:3908F566.70B61543@catlover.com...
> > syntax error at c:\inetpub\wwwroot\Test\Test.pl line 2, near ""
>
> Odds are your script is being sent to Perl.exe as a CGI script rather
> than being interpreted by Perscript. Try changing the name of your file
> to test.asp and see what happens.
>
> <%@ LANGUAGE = PerlScript %>
> <HTML>
> <BODY>
> <H1>Hello World</H1>
> <% $Response->Write("Hello!"); %>
> </BODY>
> </HTML>
------------------------------
Date: Thu, 27 Apr 2000 19:57:48 -0700
From: "Gordon Sadler" <gbsadler1@sprynet.com>
Subject: Printing integers from array
Message-Id: <8ean3b$91m$1@nntp9.atl.mindspring.net>
Hello all. Very new to perl but extremely frustrated by this seemingly
simple problem...
@numbers = {3,5,7,9}
for @numbers {
print $numbers;
}
#also tried this
for ( $i=0; $i < #$numbers; i++) {
print $numbers [$i];
}
First one prints a hash number in 0x format, second one doesnt print at all
when it compiles...
All I want is to be able to print
3 5 7 9
or
3
5
7
9
Please assist.
TIA
------------------------------
Date: Thu, 27 Apr 2000 20:53:56 -0400
From: "StreetDreams" <caraudio@streetdreams.com>
Subject: Re: Printing integers from array
Message-Id: <8eanon$7a3$1@slb2.atl.mindspring.net>
Try this:
@numbers = (3,5,7,9);
foreach $i (@numbers)
{
print $i;
}
Paul
www.streetdreams.com
Gordon Sadler <gbsadler1@sprynet.com> wrote in message
news:8ean3b$91m$1@nntp9.atl.mindspring.net...
> Hello all. Very new to perl but extremely frustrated by this seemingly
> simple problem...
>
> @numbers = {3,5,7,9}
>
> for @numbers {
> print $numbers;
> }
>
> #also tried this
>
> for ( $i=0; $i < #$numbers; i++) {
> print $numbers [$i];
> }
>
> First one prints a hash number in 0x format, second one doesnt print at
all
> when it compiles...
>
> All I want is to be able to print
> 3 5 7 9
> or
> 3
> 5
> 7
> 9
>
> Please assist.
> TIA
>
>
------------------------------
Date: Thu, 27 Apr 2000 20:14:16 -0700
From: "Gordon Sadler" <gbsadler1@sprynet.com>
Subject: Re: Printing integers from array
Message-Id: <8eao2m$d8f$1@slb7.atl.mindspring.net>
Thanks for reply. That code continues to produce a HASH(0xd6068c).
Anyone can print just the integer values?
> Gordon Sadler <gbsadler1@sprynet.com> wrote in message
> > Hello all. Very new to perl but extremely frustrated by this seemingly
> > simple problem...
> >
> > @numbers = {3,5,7,9}
> >
> > for @numbers {
> > print $numbers;
> > }
> >
> > #also tried this
> >
> > for ( $i=0; $i < #$numbers; i++) {
> > print $numbers [$i];
> > }
> >
> > First one prints a hash number in 0x format, second one doesnt print at
> all
> > when it compiles...
> >
> > All I want is to be able to print
> > 3 5 7 9
> > or
> > 3
> > 5
> > 7
> > 9
> >
> > Please assist.
> > TIA
"StreetDreams" <caraudio@streetdreams.com> wrote in message
news:8eanon$7a3$1@slb2.atl.mindspring.net...
> Try this:
>
> @numbers = (3,5,7,9);
>
> foreach $i (@numbers)
> {
> print $i;
> }
>
>
> Paul
> www.streetdreams.com
------------------------------
Date: 27 Apr 2000 18:09:01 -0700
From: Andrew Perrin - Demography <aperrin@davis.DEMOG.Berkeley.EDU>
Subject: Re: Printing integers from array
Message-Id: <u5k8zxzhw0i.fsf@davis.DEMOG.Berkeley.EDU>
"Gordon Sadler" <gbsadler1@sprynet.com> writes:
> Hello all. Very new to perl but extremely frustrated by this seemingly
> simple problem...
>
> @numbers = {3,5,7,9}
{} creates an anonymous hash reference, which is a scalar. This is
then stored in the first element of @numbers, which is why you're
getting the HASH output.
@numbers = (3,5,7,9);
>
> for @numbers {
> print $numbers;
> }
$numbers is completely unrelated to @numbers. You want:
for @numbers {
print;
}
or...
for @numbers {
print "$_\n";
}
or...
print "$_\n" for @numbers;
or...
print @numbers;
>
> #also tried this
>
> for ( $i=0; $i < #$numbers; i++) {
> print $numbers [$i];
> }
Yes, that'll work too, once you fix the original assignment, but it's
clunkier.
--
---------------------------------------------------------------------
Andrew J. Perrin - aperrin@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography - University of California at Berkeley
2232 Piedmont Avenue #2120 - Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199
------------------------------
Date: Thu, 27 Apr 2000 20:29:28 -0700
From: "Gordon Sadler" <gbsadler1@sprynet.com>
Subject: Re: Printing integers from array
Message-Id: <8eaov5$ek4$1@slb7.atl.mindspring.net>
Thank you very much, had no idea it was that particular.
All docs I read said %xx would be hash so I was confused by output.
Again thanks for quick replies.
"Andrew Perrin - Demography" <aperrin@davis.DEMOG.Berkeley.EDU> wrote in
message
> {} creates an anonymous hash reference, which is a scalar. This is
> then stored in the first element of @numbers, which is why you're
> getting the HASH output.
>
> @numbers = (3,5,7,9);
>
> >
> > for @numbers {
> > print $numbers;
> > }
>
> $numbers is completely unrelated to @numbers. You want:
>
> for @numbers {
> print;
> }
>
> or...
>
> for @numbers {
> print "$_\n";
> }
>
> or...
>
> print "$_\n" for @numbers;
>
> or...
>
> print @numbers;
>
> >
> > #also tried this
> >
> > for ( $i=0; $i < #$numbers; i++) {
> > print $numbers [$i];
> > }
>
> Yes, that'll work too, once you fix the original assignment, but it's
> clunkier.
> "Gordon Sadler" <gbsadler1@sprynet.com> writes:
>
> > Hello all. Very new to perl but extremely frustrated by this seemingly
> > simple problem...
> >
> > @numbers = {3,5,7,9}
>
> Department of Demography - University of California at Berkeley
> 2232 Piedmont Avenue #2120 - Berkeley, California, 94720-2120 USA
> http://demog.berkeley.edu/~aperrin --------------------------SEIU1199
------------------------------
Date: Thu, 27 Apr 2000 18:58:21 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Printing integers from array
Message-Id: <8ear8p$kr7$1@brokaw.wa.com>
Andrew Perrin - Demography <aperrin@davis.DEMOG.Berkeley.EDU> wrote in
message news:u5k8zxzhw0i.fsf@davis.DEMOG.Berkeley.EDU...
>
> @numbers = (3,5,7,9);
>
> for @numbers {
> print;
> }
>
> or...
>
> for @numbers {
> print "$_\n";
> }
>
Both of those give me 'syntax error at - line 2, near "for @numbers "'.
Shouldn't those be:
for (@numbers) {
print;
}
and
for (@numbers) {
print "$_\n";
}
?
> > #also tried this
> >
> > for ( $i=0; $i < #$numbers; i++) {
> > print $numbers [$i];
> > }
>
> Yes, that'll work too, once you fix the original assignment, but it's
> clunkier.
Well, not really.
for ($i=0; $i <= $#numbers; $i++) { ... }
or
for ($i=0; $i < @numbers; $i++) { ... }
:-)
Lauren
------------------------------
Date: Thu, 27 Apr 2000 22:38:33 -0400
From: "Brian Landers" <brian@bluecoat93.org>
Subject: Testing for require/use vs. execution?
Message-Id: <OQ6O4.12097$fV1.85884@news1.atl>
I'm looking for a way to determine (in a standard manner) if a file of Perl
is being executed from the command-line vs. being pulled in as a require or
use. The functionality I want is like the
if __name__ == "__main__": go()
syntax in Python - being able to insert testing or other code into a module
or library that is executed only if the file is run from the command line.
Any good ideas?
Brian
------------------------------
Date: Fri, 28 Apr 2000 10:34:31 +0800
From: "Doe" <jammerie@hotmail.com>
Subject: Thread programming
Message-Id: <8eatb8$bmu$1@newton.pacific.net.sg>
I would like to know if there are resources on the net (source codes
especially) that could teach a novice like me programming with threads. The
platform I'm working on is NT, but most of the developement work I have done
so far is on the win 9x platform with the latest version of Active Perl.
I'm developing a spider and would like to launch concurrent processes
fetching web pages from the internet, so far I have been using fork to spawn
processes. But it has been tricky establishing pipes so the HTML pages
could be piped from child to parent.
------------------------------
Date: 28 Apr 2000 00:19:15 GMT
From: feigenb@is02.fas.harvard.edu (Lee)
Subject: use overload; - interface stable?
Message-Id: <slrn8ghm83.spo.feigenb@is02.fas.harvard.edu>
Hi Everyone,
_Perl Programming_ inclues it's "Caveat Scriptor" warning that the
interface to 'use overload;' is subject to change "as it is developed
furthered."
'perldoc overload' talks about the implementation changing (and the
documentation itself needing to be rewritten!), but does not
mention the possibility of the interface changing at all...
What's the latest on this? Do people consider it `safe' to use `use
overload;' in production applications?
Thanks,
Lee
------------------------------
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 2886
**************************************