[18028] in Perl-Users-Digest
Perl-Users Digest, Issue: 188 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 1 03:05:35 2001
Date: Thu, 1 Feb 2001 00:05:16 -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: <981014715-v10-i188@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 1 Feb 2001 Volume: 10 Number: 188
Today's topics:
'print' problem <b0l4549@cs.tamu.edu>
Re: <>, tie *STDIN or *ARGV <johnlin@chttl.com.tw>
Re: Allocating ports in perl (Martien Verbruggen)
Re: Any good Perl books? <uri@sysarch.com>
Calling all DB_File Gurus. <Jodyman@usa.net>
Re: copy construct reference to anonymous scalar (Martien Verbruggen)
Re: Display URL with perl? Quick question. bits101010@my-deja.com
Re: Do threads really work? <raphael@iscusa.com>
Re: Executing external applications in Perl <jdf@pobox.com>
Re: FAQ 3.0: What is perl.com? Perl Mongers? pm.org? <comdog@panix.com>
Re: Fish v Fishing lessons - again! (was: Installing an dtbaker_dejanews@my-deja.com
Re: Fish v Fishing lessons - again! (was: Installing an <comdog@panix.com>
Re: Freelancer wanted for quickie (David H. Adler)
Re: get arrow key stroke <jdf@pobox.com>
Re: get arrow key stroke (Bernard El-Hagin)
Re: Help with headers in IE?? (Maggert)
how can I make the example go? <jck1@seed.net.tw>
Re: how do I get an IP address? (Martien Verbruggen)
Re: how do I get an IP address? wigren@mail.org
Re: How to split one program on multiple pages ? <johnm@acadiacom.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 1 Feb 2001 00:10:29 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: 'print' problem
Message-Id: <Pine.SOL.4.10.10102010006070.3492-100000@robert>
I have such a problem:
At the beginning of my code I have to use
print "content-type: text/html\n\n";
But then I want to use:
print "Location: $link\n\n";
exit;
which achieves redirection and requires not to use the first 'print' line.
How can I 'deactivate' the first 'print' line or change the print content
type?
------------------------------
Date: Thu, 1 Feb 2001 09:20:36 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: <>, tie *STDIN or *ARGV
Message-Id: <95adsi$f2e@netnews.hinet.net>
"Ilmari Karonen" wrote
> If, as PSI::ESP indicates, the real requirement is ...
[OT] what is PSI::ESP? Not found in search.cpan.org? (please help)
> Hmm.. is there a reason why you can't replace every instance of "<>"
> in the code with a function call? No need for tied handles then.
I am working on a module (as a homework I gave myself).
The intension is, when you say (or double-click it on Win32)
wperl -MGuiPerl program.pl (wperl is GUI version of perl)
it will pop-up a window of simulated console to run program.pl
(Now I use Tk::Text. Is there any better and convenient widget?)
The switch -MGuiPerl just alter the behavior whether you want to run
in simulated console or the real console, so it should be transparent to
users' programs (should not ask users to modify their program) and
this is the reason why I try to use tie.
John Lin
------------------------------
Date: Thu, 01 Feb 2001 05:49:49 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Allocating ports in perl
Message-Id: <slrn97hu5n.1up.mgjv@verbruggen.comdyn.com.au>
On Sun, 28 Jan 2001 05:25:34 GMT,
ayeletma1@my-deja.com <ayeletma1@my-deja.com> wrote:
>
> A TCP socket. I want to be able to find from a perl program which
> program use a certain socket and what is the port status.
You can only find that information out by using system specific tools.
Depending on what your netstat can tell you, you might be able to use
that. Otherwise, there is a tool called lsof out there that may be of
use to you.
Of course, I'm half guessing at what you are trying to do. The first
half of your question you can only find out for the machine you run
on. The second half is very ambiguous.
Martien
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Thu, 01 Feb 2001 04:56:07 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Any good Perl books?
Message-Id: <x7elxjrogs.fsf@home.sysarch.com>
>>>>> "p" == powerpenguin <powerpenguin@my-deja.com> writes:
p> Check out http://www.nri.ca/Bookstore/Programming/Perl/index.html for
p> books about Perl. One of my favourites include Perl in a Nutshell.
that is a stupid bookstore if all the perl books they sell are from
o'reilly. first off, not all of the ones there are really good and where
are the other well liked books like OO perl, effective perl, elements of
programming with perl, etc?
the entry for programming perl is still the 2nd edition even thought
the 3rd has been out since the summer.
i wouldn't trust this site much as a perl book resource given those
mistakes.
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: Thu, 1 Feb 2001 03:04:08 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Calling all DB_File Gurus.
Message-Id: <95b59l$gbj$1@plonk.apk.net>
The problem:
I have a few hundred GWBASIC fixed length databases in
ascii text. (The one in question, each record 512 bytes long)
I would like to be able to access the database as is from Perl.
Background:
I have downloaded and read the 25 page documentation
on DB_File from www.perl.com.
Determination:
To use DB_File using DB_RECNO file type. Quote from
documentation:
"DB_RECNO allows both fixed-length and variable-length
flat text files to be manipulated using the same key/value
pair interface as in DB_HASH and DB_TREE. In this case
the key will consist of a record (line) number."
My test program:
#!/usr/bin/perl -w
use strict;
use DB_File;
#my $c = new DB_FILE::RECNOINFO;
#$c->{'bval'} = "\r\n" ;
#$c->{'reclen'} = 512 ;
my @database;
tie @database, 'DB_File', "newcmast.dat", O_CREAT|O_RDWR, 0666, $DB_RECNO
or die "Cannot open file NEWCMAST.DAT: $!\n" ;
print "First Record is $database[1]\n";
untie @database;
Question:
When I uncomment the commented out program lines, nothing changes.
the bval isn't documented very well. GWBASIC ends each record with
a cr lf. My problem is that I had to rewrite the database and add cr lf cr
lf
to the end of each record before the above program would work. Does
anyone know the record terminator for GWBASIC Random Access Files?
My GWBASIC program:
0 ' copydb.bas
1 CLS
4 CLEAR 10000
7 OPEN "CMAST.DAT" FOR RANDOM ACCESS READ WRITE SHARED AS #1 LEN=512
8 OPEN "o", 2, "newcmast.dat"
800 '*********** FIELD DATA FILE
810 FIELD 1,4 AS T1$,30 AS T2$,30 AS T3$,30 AS T4$,20 AS T5$,2 AS T6$,9 AS
T7$,10 AS T8$,30 AS T9$,30 AS T10$,1 AS T11$,2 AS T12$,25 AS T13$,30 AS
T14$,30 AS T15$,30 AS T16$,30 AS T17$,20 AS T18$,2 AS T19$,9 AS T20$,12 AS
T21$,10 AS T22$
820 FIELD 1, 255 AS REC1$, 255 AS REC2$, 2 AS REC3$
830 EF$ = CHR$(13)+CHR$(10)
900 E = LOF(1)/512
910 FOR X = 1 TO E
920 GET 1, X
925 PRINT REC1$;REC2$;REC3$;EF$;EF$;
930 PRINT #2, REC1$;REC2$;REC3$;EF$;
940 NEXT X
950 CLOSE
960 END
------------------------------
Date: Thu, 01 Feb 2001 03:04:18 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: copy construct reference to anonymous scalar
Message-Id: <slrn97hkfl.n8t.mgjv@verbruggen.comdyn.com.au>
On Wed, 31 Jan 2001 11:20:29 +0800,
John Lin <johnlin@chttl.com.tw> wrote:
> "Martien Verbruggen"
>> John Lin wrote:
>> >
>> > my $scalar_hard_ref = \$scalar;
>> > my $scalar_copy_ref = ???????? # this is my question
>>
>> Out of curiosity, what are you going to use this for?
>
>: p No... I am just learning Perl. I like to learn in a comparative way.
>
> For example, when I learned "->", I would think of "how it applies on
> array, hash, sub, scalar, filehandle, array slice... etc.":
>
> $ref->[$i]; # for array
> $ref->{key}; # for hash
> $ref->(@param); # for sub
Which all are 'passing' some required arguments to the reference. For
an array ref, you need to specify the index in some way, for a hash
the key, and for a sub the arguments. This doesn't go for the
following:
> but we don't have
>
> $ref->??? # for scalar
> $ref->??? # for filehandle
Because I can't even imagine what would go there. there is no index,
key, or arguments to get to a scalar or filehandle.
-> doesn't really apply to what the reference refers to, it applies to
the reference itself. It dereferences it. $ref->[1] is more or less
syntactic sugar for ${$ref}[1]. A dereference of a scalar reference
looks like ${$ref}. There is nothing extra that could be applied to
the arrow operator to make it work, and I guess $ref-> without
anything extra was just considered too ugly, weird or difficult to
make it work.
The little bits after the arrow are not to refer to the reference,
but to get at a little bit that that reference refers to. In the case
of a scalar there is no such little bit to get to.
I've tried to think of something to put there, and what it would mean,
but I can't really imagine it...
> Having $ref->[$i] and $ref->{key} why Perl doesn't have
>
> $ref->[1,2,3]; # looks better than @{$ref}[1,2,3];
> $ref->{'name','address','email'}; # @{$ref}{'name','address','email'};
That's a good question. Or rather, Perl does have that, it accepts the
syntax, it just doesn't do the 'right thing' with it. I guess one
could see that as a bug, or at least a misfeature.
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 01 Feb 2001 05:49:01 GMT
From: bits101010@my-deja.com
Subject: Re: Display URL with perl? Quick question.
Message-Id: <95atcb$sql$1@nnrp1.deja.com>
Quick answer: http://search.cpan.org/search?dist=libwww-perl
In article <95a5t6$9b5$1@nnrp1.deja.com>,
pcrev@my-deja.com wrote:
> Hi I need to use a perl SSI, that will basically display the URL of
the
> page you are viewing. Does anyone know how this is done? If anyone
does,
> please email me ASAP: pete at pcrev dot com
>
> Thanks a lot!
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 31 Jan 2001 19:04:25 -0800
From: Raphael <raphael@iscusa.com>
Subject: Re: Do threads really work?
Message-Id: <3A78D239.8FEE7C5B@iscusa.com>
Andy, Dan
Thanks for your feedback, even if it is discouraging. The second model does not help us because it does not save memory and we are already using MySQL to achieve any benefits that it might offer. The first model is what we need, but it is apparently broken.
I guess we need to move to another language or rewrite a bunch of our code in C++ to shrink the size down from 30M to something more manable and build this code into Perl.
We hold all the data in MySQL in any case so it should would have been a breeze to make SupportWizard thread-safe (you can kill the Perl process while a user is active and apart from slightly sluggish performance while a new process is started up, he will never notice that it happened).
If only Perl supported something like shared object libraries....
Any ideas for shrinking the size of the processes would be welcome.
Raphael.
PS: For readers who want more details on Perl threads the following information was obtained by one of my co-developers:
Ok, what can i say after couple of days trying to find out stableness threads using at perl5.6.
1. There were threads support ever at 5.005 version and still that part is experimental.
2. Now at 5.6 version are two different multithreading schemes (5005 and interpretator-based - see differens latter at the mail), one more interesting feature is multiplicity (see latter).
3. Most modules that 'can' use threads (actually i find only one -Net::Daemon ;-) work only with first scheme(5005) and fails use second one. Some, like DBI
http://www.perl.com/pub/1999/09/topaz.html
http://www.perl.com/pub/2000/01/10PerlMyths.html
http://www.perl.com/pub/2000/04/whatsnew.html
http://www.perl.com/pub/2000/07/perl6.html
http://www.perl.com/pub/language/versus/
Better support for multiple interpreters
The build-time option `-DMULTIPLICITY' has had many of the details reworked. Some previously global variables that should have been per-interpreter now are. With care, this allows interpreters to call each other. See the `PerlInterp' extension on CPAN.
Threads
WARNING: Threading is considered an experimental feature. Details of the implementation may change without notice. There are known limitations and some bugs. These are expected to be fixed in future versions.
Threads
Dan Sugalski submitted a patch that makes a new locking macro available to XS code, but Sarathy said:
Every time I see people patching USE_THREADS code I wonder if it's all going to be for nothing. I don't see much hopefor salvaging the existing model of USE_THREADS where prolific locking is needed.
In case you missed the point of this: 5.005_63 is going to have a drastically different threading model than previous versions of Perl. I asked Dan to explain the two models to me, and he very kindly contributed the following:
--------------------------------------------------------------------------------
Shared Interpreter threads (the current model)
This threading model corresponds pretty closely to what most folks think of when they think of threads. There is a single, shared executable (or optree, in perl's case), and a single pool of variables. Any thread can see, and affect, anything that's in its lexical scope. Data sharing between threads is cheap, but the onus is on the programmer to maintain consistency.
As an analogy, consider a thread a hamster, and your program as a giant habitrail. Starting another thread means releasing another hamster into the environment. Threads don't really collide (You ever see two hamsters get stuck in a habitrail tube?) but the only thing that keeps two or more hamsters from running on an exercise wheel at once is careful design of the set.
Cloned interpreter threads (upcoming in 5.005_63)
This threading model corresponds more to the traditional unix fork model. There is one copy of the optree per thread. One thread can't see or affect anything in another thread unless that thing is explicitly shared. Data sharing and coordination between threads is mildly expensive and a bit cumbersome, but the onus is on the perl interpreter to keep one thread from messing with another thread's
toys.
Continuing the hamster analogy, creating a new thread in this model gets you a whole new, separate habitrail for your new hamster. The two habitrails may share exercise wheels, but only at very specific, explicit spots, and there are little exclusion gates built in so only one hamster can be on a wheel at once.
My personal preference is a bit mixed--I want shared threads because they let me build all sorts of cheap, nifty tools (Threaded objects, and a subclassable Thread::Object, are I. I know, I wrote a package to do it. One thread per object. Wheee!), but I think most folks (including me, when writing 'normal' code) are better off with the protection cloned threads get you.
The trickier bit is under the hood. Getting perl thread-safe (which is to say, it won't core or segfault if the programmer doesn't sync access) is a PITA. I've already run through a couple of different plans--the first was paranoid and I, the second bloated libperl.so with a lot of shadow routines for XS, and the third I'm not gonna bother with if threads are dead anyway.
It does chew up more memory, too. To do it right means each and every variable needs a mutex as well, otherwise you run into deadlock issues and uneccesary lock contention. 'Course, it makes $foo[time] cost even more than it does now. The alternative is "e;just don't do that"e;, but that's not really an option I like.
Most of the p5p folks with an opinion prefers the forkish version. I think they're all wrong, of course, but that's just me. :-)
--------------------------------------------------------------------------------
Thank you very much, Dan.
Dan requested that Sarathy commit one way or the other on the existing threading model. Sarathy said that he wasn't sure yet, because he needs to see how the new way works out, but he guesses that Perl will go with the new way.
http://www.perl.com/pub/doc/manual/html/pod/perlembed.html
Maintaining multiple interpreter instances
Some rare applications will need to create more than one interpreter during a session. Such an application might sporadically decide to release any resources associated with the interpreter.
The program must take care to ensure that this takes place before the next interpreter is constructed. By default, the global variable PL_perl_destruct_level is set to 0, since extra cleaning isn't needed when a program has only one interpreter.
Setting PL_perl_destruct_level to 1 makes everything squeaky clean:
PL_perl_destruct_level = 1;
while(1) {
...
/* reset global variables here with PL_perl_destruct_level = 1 */
perl_construct(my_perl);
...
/* clean and reset _everything_ during perl_destruct */
perl_destruct(my_perl);
perl_free(my_perl);
...
/* let's go do it again! */
}
When perl_destruct() is called, the interpreter's syntax parse tree and symbol tables are cleaned up, and global variables are reset.
Now suppose we have more than one interpreter instance running at the same time. This is feasible, but only if you used the -DMULTIPLICITY flag when building Perl. By default, that sets PL_perl_destruct_level to 1.
Let's give it a try:
#include <EXTERN.h>
#include <perl.h>
/* we're going to embed two interpreters */
/* we're going to embed two interpreters */
#define SAY_HELLO "-e", "print qq(Hi, I'm $^X\n)"
int main(int argc, char **argv, char **env)
{
PerlInterpreter
*one_perl = perl_alloc(),
*two_perl = perl_alloc();
char *one_args[] = { "one_perl", SAY_HELLO };
char *two_args[] = { "two_perl", SAY_HELLO };
perl_construct(one_perl);
perl_construct(two_perl);
perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
perl_parse(two_perl, NULL, 3, two_args, (char **)NULL);
perl_run(one_perl);
perl_run(two_perl);
perl_destruct(one_perl);
perl_destruct(two_perl);
perl_free(one_perl);
perl_free(two_perl);
}
Compile as usual:
% cc -o multiplicity multiplicity.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
Run it, Run it:
% multiplicity
Hi, I'm one_perl
Hi, I'm two_perl
------------------------------
Date: 01 Feb 2001 01:47:08 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Executing external applications in Perl
Message-Id: <u26eoq6r.fsf@pobox.com>
"Magma" <peter@viasafe.com> writes:
> I'm working on Windows NT 4.0.
I'm sorry.
> What I need to do is run an application ( a ".exe") with a list of
> parameters and read back what this application writes to the console
> (to parse the various return values).
In that case you have two options. You may run the process either
with the qx// operator (documented in perlop, and also spelled with
"backticks", the `` characters), or by using the open() function with
the "|" mode character, documented in perlfunc and in perlipc.
> I have tried setting the path with another system() command ("set
> path blah blah..."), with no success. How can I get this app to run
> as if I were runing it from it's home directory?
When you use the system() function, you spawn a new process, with its
own copy of the environament; PATH, for example, is an environment
variable. When that process is done, any changes you've made to its
environment are gone with the process itself.
What you need is to change your parent process's CWD, its current
working directory. See the chdir() function in perlfunc.
> My email is peter@viasafe.com.
In that case, I've got for you a terrific plan to make $20,000 in 3
months, tax free!!!!! Just hit your reply button and put
"Unsubscribe" in the subject header to be removed from this list.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Thu, 01 Feb 2001 02:57:34 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: FAQ 3.0: What is perl.com? Perl Mongers? pm.org? perl.org?
Message-Id: <comdog-3B594B.02573401022001@news.panix.com>
In article <N38e6.1528$B9.195708416@news.frii.net>, PerlFAQ Server
<faq@denver.pm.org> wrote:
> Perl Mongers is an advocacy organization for the Perl language. For
> details, see the Perl Mongers web site at http://www.perlmongers.org/.
that should be www.perl.org.
[dha - what's up with that ;) ]
> AUTHOR AND COPYRIGHT
>
> Copyright (c) 1997-1999 Tom Christiansen and Nathan
> Torkington. All rights reserved.
there's a problem here. i think dha wrote the most (if not all)
of the content of that answer.
--
brian d foy <comdog@panix.com>
------------------------------
Date: Thu, 01 Feb 2001 05:11:12 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Fish v Fishing lessons - again! (was: Installing and using modules when you're not root?)
Message-Id: <95ar5d$r19$1@nnrp1.deja.com>
In article <u9snm1q6el.fsf@wcl-l.bham.ac.uk>,
nobull@mail.com wrote:
> If you give a man fish he won't go hungy today. If you teach a man to
> fish he'll won't go hungry until the fish stocks are exhaused. The
> Perl manuals are well-stocked rivers.
>
> Please do _not_ hand out fish to the newcommers.
----------------
but there is a difference between showing someone how to find a fishing
pole, and whacking them over the head with a stick they didnt even know
was there... and making them feel stupid about it.
I know that many times I cant find things in the perldocs even after a
good half hour of looking unless someone helps with what area to look
in. Many times when I DO find something in perldocs it is lacking...
either in clarity or perhaps an example. To tell you the truth I usually
get a faster start with deja.com searches, but then I have to weed thru
all the RTFM responses to find one that is actually useful in many
cases.
D
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 01 Feb 2001 02:53:41 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Fish v Fishing lessons - again! (was: Installing and using modules when you're not root?)
Message-Id: <comdog-5B3029.02534101022001@news.panix.com>
In article <95ar5d$r19$1@nnrp1.deja.com>, dtbaker_dejanews@my-deja.com
wrote:
> I know that many times I cant find things in the perldocs even after a
> good half hour of looking unless someone helps with what area to look
> in.
sounds like you need
http://www.perldoc.com
--
brian d foy <comdog@panix.com>
------------------------------
Date: 1 Feb 2001 05:22:55 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: Freelancer wanted for quickie
Message-Id: <slrn97hslf.ebk.dha@panix6.panix.com>
On Wed, 31 Jan 2001 08:04:06 -0000, Rhidian Jones wrote:
>Right person can expect plenty of freelance work in the future
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Please do not throw hands at me. - D84, Robots Of Death
------------------------------
Date: 01 Feb 2001 01:49:49 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: get arrow key stroke
Message-Id: <puh2oq2a.fsf@pobox.com>
Beggar <cpegbeggar@mail.com> writes:
> How can I check if the user has press the arrow keys? (up, down,
> left, right)
This is a FAQ, addressed in the perlfaq5 manual.
"How can I read a single character from a file? From the keyboard?"
> Please cc reply to cpegbeggar@mail.com
"Post here, read here" is my motto.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Thu, 1 Feb 2001 07:31:42 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: get arrow key stroke
Message-Id: <slrn97i46q.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 01 Feb 2001 02:04:34 +0800, Beggar <cpegbeggar@mail.com> wrote:
>Hi all,
>
>How can I check if the user has press the arrow keys?
>(up, down, left, right)
perldoc -q keyboard
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 01 Feb 2001 04:16:37 GMT
From: perl@imchat.com (Maggert)
Subject: Re: Help with headers in IE??
Message-Id: <3a78e2e1.7422623@news.ionet.net>
On Thu, 01 Feb 2001 01:01:04 GMT, Jason Hurst <gorgano@altavista.com>
wrote:
>ok, here is a fun one. I've got these binary files i want to send to
>the browser. Now because of sercurity stuff i'm using a perl script to
>read in the file and then send it on it's way. Pretty basic, open the
>file, bindmod it and stdout, then do a read() and simply print out the
>data a little bit at a time. Works fine in netscape, but for some
>reason when i'm using IE, it First prompts if i want to save or open
>the script file, if you hit open, it then asks if you want to save or
>open the script file AGAIN, hit open, and THEN it asks if you want to
>save the file. Anyone seen anything like this? the headers i'm using
>are like this:
>
>Content-Disposition: attachment; filename="addbook-1.0.tar.gz"
>Content-Type: application/octet-stream
>
>NOte this also happens on text/plain, but not with text/html..
>
>any guesses? Thanks for your help!
>
IE doesn't have a clue what Mime headers are. You have to
learn to trick it with /path info.
------------------------------
Date: Thu, 01 Feb 2001 09:33:59 +0800
From: jck1 <jck1@seed.net.tw>
Subject: how can I make the example go?
Message-Id: <3A78BD06.A24B7240@seed.net.tw>
Hi, all. This is jck1 speaking.
I adapt the example from a book called "advance perl programing".
In my pc, the linux Redhat 6.2 system, it does't work.
How can I make it work? The code is below.
---------------------------------------------------------
##filename:search.pl
sub search_files{
my($pattern, $filepattern)=@_;
local(@ARGV)=glob($filepattern);
return unless(@ARGV);
while(<>){
if(/$pattern/o){
print "$ARGV\[$.\] $_";
}
}
}
##filename:ex01.c
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
main(int argc, char **argv, char **env){
char *my_argv[]={"struct","*.h",NULL};
my_perl=perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, argc, argv, env);
perl_call_argv("search_files", G_DISCARD, my_argv);
perl_destruct(my_perl);
perl_free(my_perl);
}
---------------------------------------------------------
I try the command to compile the ex01.c
#gcc -o ex01 -I/usr/lib/perl5/5.00503/i386-linux/CORE
-L/usr/lib/perl5/5.00503/i386-linux/CORE -Dbool=char -DHAS_BOOL ex01.c
-lperl -lm
Then I get the error messag .
/usr/lib/perl5/5.00503/i386-linux/CORE/libperl.a(pp.o): In function
`Perl_pp_crypt':
pp.o(.text+0x5933): undefined reference to `crypt'
collect2: ld returned 1 exit status
That's all.
How can I make it work?
What is the libperl.a and what it do?
Thanks for your helping...... :)
------------------------------
Date: Thu, 01 Feb 2001 06:01:57 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: how do I get an IP address?
Message-Id: <slrn97husf.1up.mgjv@verbruggen.comdyn.com.au>
On 31 Jan 2001 18:00:31 -0500,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> "Storm" <storm@isbangelijk.com> writes:
>
>> how do I get an ip addres of my network card?
> ^^^^^^^^^
> % perldoc -q "ip addres"
The answer you get there isn't necessarily the answer to the OP's
question. The question is ambiguous enough to be interpreted in
various ways.
1) The OP has one network card, and no other interfaces up. He/She is not
interested in 127.0.0.1. The FAQ answers this question.
2) The OP is interested in the IP address that belongs to the name of
the host he/she's on. The FAQ answers this.
3) The OP has potentially multiple interfaces, and has multiple IP
addresses. He/She wants to know one of those IP addresses.
(improbable, because of the singular 'card' but still...)
4) The OP has multiple interfaces, and is interested in a specific IP
address configured on one of them. The FAQ doesn't cover this.
(equally improbable).
5) The OP's host has a name that isn't resolveable through DNS (i.. or
other means. My laptop has this when it's connected to the network at
work. The DNS at work knows it by a different name). The FAQ doesn't
cover this.
Just too ambiguous, that question. And cases 3 and 4 get asked here
frequently enough for me not to assume anymore that someone is in
situation 1 or 2.
>> this must be os independant
>
> ?!?
depending on what exactly the OP needs, this could be OS specific.
>> you may not use the program "ipconfig.exe" and
>> then parse every line until you have found the ip
Then you cannot do it, unless you write long ugly pieces of syscall
stuff with OS specific calls, or you use Inline::C with OS specific
stuff. Just call ipconfig if you need it. If instead you are really
trying to ask the question the FAQ answers, then use that method.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Thu, 01 Feb 2001 07:03:10 GMT
From: wigren@mail.org
Subject: Re: how do I get an IP address?
Message-Id: <95b1nc$vu7$1@nnrp1.deja.com>
I guess it's better to check the IP of the device that "default gateway"
uses... That is more likely to give the IP you want.
Now, beeing quite a Perl-newbie myself (I have programmed a lot in other
languages though), I can't tell you how to implement that
OS-independant...
Regards
Per Wigren
In article <95a4of$8a0$1@nnrp1.deja.com>,
jimjim123@my-deja.com wrote:
> Aye, use the Sys::Hostname which gives you the hostname, then you can
> query a DNS to get the IP.... If you consult perldoc, it returns the
> following useful information...
>
> use Socket;
> use Sys::Hostname;
> my $host = hostname();
> my $addr = inet_ntoa(scalar gethostbyname($host ||
> 'localhost'));
>
> Cheers!
>
> H.
>
> In article <iA%d6.311379$MA1.10182911@afrodite.telenet-ops.be>,
> "Storm" <storm@isbangelijk.com> wrote:
> > how do I get an ip addres of my network card?
> >
> > this must be os independant
> > you may not use the program "ipconfig.exe" and then parse every line
> until
> > you have found the ip
> >
> > has perl a function to do this?
> >
> >
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 1 Feb 2001 01:39:32 -0600
From: "John Michael" <johnm@acadiacom.net>
Subject: Re: How to split one program on multiple pages ?
Message-Id: <3a7914a3@news.acadiacom.net>
Take your subs and put them in another file and require them like so at the
top of your main perl script.'
use "mysubs.pl";
When the script runs, it will pull the subs into it.
I like to write my subs like this one with my variables:
############################################################################
##############
sub parse_form {
my (@pairs,$buf);
read (STDIN, $buf, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buf);
return @pairs;
}
############################################################################
##############
sub assign_values {
my @array = @_;
my ($name,$value);
foreach (@array) {
chomp;
($name, $value) = split(/=/);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$INPUT{$name} = $value;
}}
############################################################################
##############
I can not put these in a seperate file and acquire them.
then I can call them like this.
@array = &assign_values(&parse_form);
I have just moved 2 whole subs into another .pl file and used them with one
line to return the array. You can also use the assign values sub with this
sub:
############################################################################
##############
sub get_query {
my @pairs;
if ($ENV{'QUERY_STRING'}){
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}else {&error('query_missing')};
return @pairs;
}
############################################################################
##############
like so:
@array = &assign_values(&get_query);
I have subs for opening files, outputing to files, and appending files. I
also put my error handlers in seperate programs also. I have one big file
that I keep all of my subs that I have written in almost like people write
modules. I can then require them and use them over and over in diffrerent
programs.
Hope this is what you were looking for.
Oh, one other thing. You can do alot of the stuff above with CGI.pm.
cya
john michael
"Nikolaj van Omme" <nvanomme@smg.cutoff.ulb.ac.be> wrote in message
news:3A781FD0.B32A7388@smg.cutoff.ulb.ac.be...
> Hello,
>
> I didn't find the answer in the FAQ (but there are so many that I
> couldn't read everything).
>
> I would like to write a huge program (thousands of lines) and to split
> it in different files in the same directory or in different directories.
> I do not need to make modules.
>
> (I can make modules if someone could tell me how to share all the global
> variables in the program and in the modules (i.e. I want to use a global
> variable of the program into a module and, vice-versa, I want to use a
> global variable from the module into the main program whitout naming my
> variables like $MAIN::VARIABLE)).
>
> Could somebody help me ? Thanks a lot,
>
> Nikolaj
> --
> Nikolaj van Omme
> nvanomme@smg.ulb.ac.be
------------------------------
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 188
**************************************