[19809] in Perl-Users-Digest
Perl-Users Digest, Issue: 2004 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 25 03:10:31 2001
Date: Thu, 25 Oct 2001 00:10:15 -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: <1003993815-v10-i2004@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 Oct 2001 Volume: 10 Number: 2004
Today's topics:
Shebang line question <nospam@nospam.com>
Re: Shebang line question <jeff@vpservices.com>
Re: Shebang line question <nospam@nospam.com>
Re: Shebang line question (Andre Malo)
Re: Split on Win32 <goldbb2@earthlink.net>
Re: Strange behavior w/ SIGALRM and POSIX::sigaction- w <goldbb2@earthlink.net>
Re: Telnet client in perl <sdidrik@rmci.net>
Re: Transfer to & from remote machine using telnet (David Chan)
use re "debug" <rtrahan@monmouth.com>
variable-length parameter lists from Perl -> C (Jennifer Cranfill)
Re: variable-length parameter lists from Perl -> C <andrew@erlenstar.demon.co.uk>
Re: What the **** is WRONG with this!? <pne-news-20011025@newton.digitalspace.net>
Re: What's wrong with File::Find (Mark Jason Dominus)
Re: What's wrong with File::Find <dtweed@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Oct 2001 18:02:38 +1300
From: "Charlie" <nospam@nospam.com>
Subject: Shebang line question
Message-Id: <9r86af$rd6$1@lust.ihug.co.nz>
Hi,
I am running Windows ME at home and subesquently have the following #! line
in my scipts for testing:
#!E:\Programs\Perl\bin\perl
When I upload my programs to my UNIX server, I need to have the following
line instead:
#!/usr/bin/perl
Is there any technique that will save me from having to manually go and
change this line everytime I upload to the UNIX server?
Sorry if this question is dumb...
Thanks
Charlie
------------------------------
Date: Wed, 24 Oct 2001 22:08:36 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Shebang line question
Message-Id: <3BD79E54.46963715@vpservices.com>
Charlie wrote:
>
> I am running Windows ME at home and subesquently have the following #! line
> in my scipts for testing:
> #!E:\Programs\Perl\bin\perl
>
> When I upload my programs to my UNIX server, I need to have the following
> line instead:
> #!/usr/bin/perl
>
> Is there any technique that will save me from having to manually go and
> change this line everytime I upload to the UNIX server?
If you are not running a web server on your win box, then just change
the shebang to #!/usr/bin/perl -w and it should run fine from the
command line because windoze finds the perl executable by other means
than the shebang line although it does use whatever switches you put
there.
If you are running a web server on your win box, then your shebang line
has to do whatever the web server wants. Personally I just installed
activestate perl in #!c:/usr/local/ and use apache for windows with the
same shebang as on my unix boxes: #!/usr/local/bin/perl -w.
--
Jeff
------------------------------
Date: Thu, 25 Oct 2001 18:26:32 +1300
From: "Charlie" <nospam@nospam.com>
Subject: Re: Shebang line question
Message-Id: <9r87na$siu$1@lust.ihug.co.nz>
Cheers Jeff,
That makes sense.
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3BD79E54.46963715@vpservices.com...
> Charlie wrote:
> >
> > I am running Windows ME at home and subesquently have the following #!
line
> > in my scipts for testing:
> > #!E:\Programs\Perl\bin\perl
> >
> > When I upload my programs to my UNIX server, I need to have the
following
> > line instead:
> > #!/usr/bin/perl
> >
> > Is there any technique that will save me from having to manually go and
> > change this line everytime I upload to the UNIX server?
>
> If you are not running a web server on your win box, then just change
> the shebang to #!/usr/bin/perl -w and it should run fine from the
> command line because windoze finds the perl executable by other means
> than the shebang line although it does use whatever switches you put
> there.
>
> If you are running a web server on your win box, then your shebang line
> has to do whatever the web server wants. Personally I just installed
> activestate perl in #!c:/usr/local/ and use apache for windows with the
> same shebang as on my unix boxes: #!/usr/local/bin/perl -w.
>
> --
> Jeff
>
------------------------------
Date: 25 Oct 2001 05:44:37 GMT
From: ndparker@gmx.net (Andre Malo)
Subject: Re: Shebang line question
Message-Id: <Xns91454FE92ED75ndparker@news.o3media.de>
* Charlie wrote in news:9r86af$rd6$1@lust.ihug.co.nz:
> I am running Windows ME at home and subesquently have the following #!
> line in my scipts for testing:
> #!E:\Programs\Perl\bin\perl
>
> When I upload my programs to my UNIX server, I need to have the
> following line instead:
> #!/usr/bin/perl
>
> Is there any technique that will save me from having to manually go and
> change this line everytime I upload to the UNIX server?
if you're using the Apache web server, you may want to try the
ScriptInterpreterSource directive.
<http://httpd.apache.org/docs/mod/core.html#scriptinterpretersource>
nd
--
die (eval q-qq:Just Another Perl Hacker
:-)
# n.d. parker, http://www.o3media.de/ #
------------------------------
Date: Thu, 25 Oct 2001 02:18:41 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Split on Win32
Message-Id: <3BD7AEC1.1FFB3E91@earthlink.net>
Gregski wrote:
>
> Bernard, Simon,
>
> Thanks, you're both right - it is something I overlooked - those angle
> brackets!! However why does it work, and why does the output look as
> though it splits on whitespace?
Because in this context, the angle brackets <> aren't doing a filehandle
read, they are doing glob. The way glob works is it first splits [on
whitespace] into seperate glob-expressions, and for each one, looks for
a file which matches that expression, and if it doesn't find such a
file, it returns the glob-expression unchanged.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Thu, 25 Oct 2001 01:44:11 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Strange behavior w/ SIGALRM and POSIX::sigaction- was (Re: alarm and put a timeout on a perl program an its shell childs ?)
Message-Id: <3BD7A6AB.345F6B04@earthlink.net>
Joe Schaefer wrote:
[snip]
> I have a related question that I haven't been able to solve.
> The following code does hostname lookups via gethostbyname()
> which is wrapped in a 2 second alarm:
[snip]
> eval {
> sigaction(SIGALRM, POSIX::SigAction->new("main::alrm"));
> alarm 2;
> $addr = gethostbyname $_;
> alarm 0;
> };
[snip]
> Now the problem is that once the alarm is triggered,
> *all* subsequent gethostbyname lookups are failing.
[snip]
> Does somebody understand what is going on here?
The internal data structures used by gethostbyname are left in an
inconsistant state when the alarm goes off.
I would suggest that instead of doing gethostbyname, you use Net::DNS.
Yes, there's an annoying amount of overhead, but the alternatives are to
either do the lookup in another thread/process, or to not use a timeout.
[as to doing it in another process/thread -- create a pair of pipes,
fork, have the child process read from the first pipe, do the lookup,
and write to the other pipe, have the parent process write the name to
be loooked up to the first pipe, use select/IO::Select on the second for
the timeout, then sysread the looked up address from the pipe. If the
select times out, kill the child process and start a new one.]
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 24 Oct 2001 20:42:02 -0400
From: scott <sdidrik@rmci.net>
Subject: Re: Telnet client in perl
Message-Id: <RWKB7.50211$6i7.5986758@e420r-atl1.usenetserver.com>
Joe Schaefer wrote:
> "Scott Bell" <news@scottbell.org> writes:
>
>> Does anyone know of a telnet client in perl, I'm not looking for a
>> telnet.pm module, an actual perl script.
>
> % perl -MCPAN -e "install Net::Telnet"
> % perldoc Net::Telnet
>
If you want a pretty good book about Perl and Networking, including
Net::Telnet try Lincoln Stein's "Network Programming with Perl". It goes
into pretty good detail. The Net::Telnet docs are pretty good also.
scott
--
scott
sdidrik@rmci.net
------------------------------
Date: 25 Oct 2001 05:58:14 GMT
From: david@s.h.e.e.t.m.u.s.i.c.org.uk (David Chan)
Subject: Re: Transfer to & from remote machine using telnet
Message-Id: <9r89lm$ruj$1@news8.svr.pol.co.uk>
In article <9r7kef$fki$1@charity.cs.utexas.edu>, Logan Shaw wrote:
> Mina Naguib <spam@thecouch.homeip.net> wrote:
>>"Anand Ramamurthy" <anand_ramamurthy@yahoo.com> wrote:
>>> I have need to tansfer file(s) to & froma remote machine using through
>>> telnet (not ftp or any other means). Is this possible? If yes, is
>>> there an example perl script for the same.
>>
>>Telnet is not a file transfer protocol. The simple answer is no.
>>
[...]
> Aw, it's not that hard. You don't need error checking, since error
> checking should be happening at the TCP stream level.
>
> Last time I found myself in this situation, I was using two Unix
> machines, so I simply did this:
>
> 1. Type "uuencode myfile myfile > myfile.uu" on the remote machine.
> 2. Turn on the "Log to File" option in xterm.
> 3. Type "cat myfile.uu".
> 4. Turn off the "Log to File" option in xterm.
> 5. Edit the logfile, delete extra stuff at beginning/end,
> and type "uudecode logfile".
Pretty. But you don't need to use xterm, you can just do
"telnet othercomputer | tee logfile.txt", and you probably don't need
to delete the crap (as long as you don't have a prompt beginning "begin"
or anything weird like that)
--
David
------------------------------
Date: Wed, 24 Oct 2001 23:57:01 -0700
From: Richard Trahan <rtrahan@monmouth.com>
Subject: use re "debug"
Message-Id: <3BD7B7BD.19E17063@monmouth.com>
I'm running ActivePerl on W98. When I run the example on Wall,
p. 195-6 (which demonstrates 'use re debug' on a simple string), I
don't get the line "Omitting $` $& $' support".
I believe the omission of those values is an optimization that is
guaranteed if one never uses them. Does this mean that the ActiveState
port has somehow lost this optimization?
------------------------------
Date: 24 Oct 2001 18:38:29 -0700
From: cranfill@lclark.edu (Jennifer Cranfill)
Subject: variable-length parameter lists from Perl -> C
Message-Id: <23def12e.0110241738.aa54dfa@posting.google.com>
Hello,
I am trying to write a Perl to C extension that passes variable-length
parameters lists (of mixed variable types) from Perl to C. While I
know how to pass variable-length argument lists from Perl to my XS
code, and how to use the va_lists from within C, I am not sure how to
then call a C function with this variable number of arguments.
I asked the perl-xs mailing list and the response was that this is
pretty much impossible and that a switch will have to be implemented
to try as many cases as possible. As I would like there to be an
infinite number of possibilities, I am still searching for another
option. Has anyone had experience passing variable-length parameter
lists from Perl to C?
Below is a sample of my XS code and the corresponding compilation
errors:
I tried to do a va_list in my XS code, using the stdarg.h file:
int
c_log(logptr, defaultMessage, ...)
ct_log_ptr * logptr
const char * defaultMessage
PREINIT:
va_list ap;
CODE:
va_start(ap, defaultMessage);
RETVAL = log(*logptr, defaultMessage, ap);
OUTPUT:
RETVAL
However when I compile I get this error:
logAPI.xs: In function `XS_clogAPI_c_log':
logAPI.xs:142: `va_start' used in function with fixed args
Thanks in advance.
--Jennifer
------------------------------
Date: 25 Oct 2001 05:38:43 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: variable-length parameter lists from Perl -> C
Message-Id: <878ze0uyek.fsf@erlenstar.demon.co.uk>
>>>>> "Jennifer" == Jennifer Cranfill <cranfill@lclark.edu> writes:
Jennifer> Hello,
Jennifer> I am trying to write a Perl to C extension that passes
Jennifer> variable-length parameters lists (of mixed variable types)
Jennifer> from Perl to C. While I know how to pass variable-length
Jennifer> argument lists from Perl to my XS code, and how to use the
Jennifer> va_lists from within C, I am not sure how to then call a C
Jennifer> function with this variable number of arguments.
In simple terms you can't. The variable argument list stuff in C
requires that the number of parameters being passed is known at the
time that the call is compiled; when your XS code is compiled you have
no way of knowing how many arguments will be passed from the Perl
code, and the normal variable argument mechanism doesn't work for XS
routines because they use the Perl stack for arguments.
The only way that works regardless of the number of arguments is to
synthesise an argument list and a va_list variable pointing to it, but
this requires detailed knowledge of the parameter-passing conventions
of your compiler and is not at all portable. Furthermore, you have to
know or deduce the correct C-language types of all the Perl values
passed in.
It looks like what you're trying to do in this case is to provide an
sprintf-type interface. The way to do that is to push the problem up
one level and call sprintf() directly from Perl, and pass the resulting
string to your XS function.
--
Andrew.
------------------------------
Date: Thu, 25 Oct 2001 07:39:47 +0200
From: Philip Newton <pne-news-20011025@newton.digitalspace.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <as7ftt40v3bl6kca37d4nbis6mro02vafo@4ax.com>
On 24 Oct 2001 04:56:46 GMT, "David H. Adler" <dha@panix.com> wrote:
> In article <Xns9143D27FBA15615497002270367234@24.2.10.79>, Graham W.
> Boyes wrote:
>
> > Aren't newsgroups great? If you need a computer hardware question or
> > networking question answered, feel free to visit
> > 24hoursupport.helpdesk.
>
> And, *boy*, don't we wish there was such a hierarchy for us to send
> people to! :-)
Well, there's alt.dev.null ....
(Which my news server will not let anyone post or followup to.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 25 Oct 2001 03:18:22 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: What's wrong with File::Find
Message-Id: <3bd7847c.1747$242@news.op.net>
In article <3BD74A01.C3A62D5B@acm.org>, Dave Tweed <dtweed@acm.org> wrote:
>Mark Jason Dominus wrote:
>> >find(sub { mysub(@myargs) }, '/', '/tmp');
>>
>> It has the same effect because it is the same suggestion. You are
>> using a closure, as Alexander suggested.
>
>Not all anonymous subs are closures.
In Perl, all anonymous subs are closures.
>In this case, there's no binding to a lexical variable outside any
>caller's scope;
There is if there was a decalaration of my @myargs that the original
poster didn't show.
Regardless, a closure is not required to capture an outer lexical
variable. It is only required to be closed. Subs that do not refer
to outer lexical variables are trivially closed.
> @myargs is passed by value.
Whether it is (and it isn't) is irrelevant since it has nothing to do
with whether there is a closure.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 25 Oct 2001 04:18:46 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: What's wrong with File::Find
Message-Id: <3BD79143.66E3AEEA@acm.org>
Mark Jason Dominus wrote:
> In article <3BD74A01.C3A62D5B@acm.org>, Dave Tweed <dtweed@acm.org> wrote:
> >Not all anonymous subs are closures.
> In Perl, all anonymous subs are closures.
I don't think so.
perlfaq7:
Closures are implemented in Perl as anonymous subroutines with lasting
references to lexical variables outside their own scopes.
and further down:
The anonymous subroutine returned by add_function_generator() isn't
technically a closure because it refers to no lexicals outside its
own scope.
perlref:
Note particularly that $x continues to refer to the value passed
into newprint() I<despite> "my $x" having gone out of scope by the
time the anonymous subroutine runs. That's what a closure is all
about.
All other references to closures that I can find in the pods refer
specifically to the binding of lexical variables that have gone out
of scope.
Now, was the OP objecting to "closures" as defined in the docs, or
to anonymous subs in general?
-- Dave Tweed
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 2004
***************************************