[17114] in Perl-Users-Digest
Perl-Users Digest, Issue: 4526 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 5 03:05:35 2000
Date: Thu, 5 Oct 2000 00:05:10 -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: <970729510-v9-i4526@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Oct 2000 Volume: 9 Number: 4526
Today's topics:
Re: cgi script runs ok, but pages mysteriously get larg <jeff@vpservices.com>
cgi script runs ok, but pages mysteriously get larger a (Eric White)
Re: cgi script runs ok, but pages mysteriously get larg <philipg@atl.mediaone.net>
Re: CGI trouble Rand25@juno.com
Re: embedding in HTML <philipg@atl.mediaone.net>
Re: Executing exe from webpage Rand25@juno.com
Formating output to be read in a form. <verybig@thebedroom.co.uk>
Re: Formating output to be read in a form. <jeff@vpservices.com>
Re: Formating output to be read in a form. (Chris Fedde)
Re: Formating output to be read in a form. (Martien Verbruggen)
Re: How to find IP address by MAC address? (Chris Fedde)
Re: How? Read a file from another server? <webmaster@cobnet.com>
LWP ->How to stop a redirect and work with cookies littlemanjohn@my-deja.com
Re: multiple forms FAQ <philipg@atl.mediaone.net>
Re: Need the best Perl Tutorial -- bar none <01031149@3web.net>
Re: Net::SMTP problem (Martin Vorlaender)
Re: OT: Re: CGI trouble Rand25@juno.com
Re: printing a postscript file directly <bcaligari@my-deja.com>
Re: Searching for spaces in a string only getting the b (Rafael Garcia-Suarez)
Re: ssh and vnc on nt via perl <taboo@comcen.com.au>
Re: SSI in a CGI <millerd@ns1.rli-net.net>
Re: Threads and SMP <philipg@atl.mediaone.net>
Re: Threads and SMP (Martien Verbruggen)
Re: timeout on user input on NT <elephant@squirrelgroup.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Oct 2000 21:53:17 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: cgi script runs ok, but pages mysteriously get larger as it progresses
Message-Id: <39DC093D.85427408@vpservices.com>
Eric White wrote:
>
> Ok, I've got a cgi script that's about 2mb in size.
Aye yi yi yi yi! Time to move the text out into a database or directory
of text files and use a templating module like HTML::Mason to produce
the pages from it. That ought to shrink your script down to something
manageable. (if I am correctly guessing the reason for the size of your
script)
> It generates a series of
> forms and moves the user from page to page (about 40 in total). This is all
> fine, for the most part, but I've discovered that as I go from page 3 to 4, 4
> to 5, etc, the size of the next page (in kb - the actual number of bytes
> passed back to the browser) seems to grow with each advancing page. This
> isn't because the pages themselves get bigger; they're just text and all
> roughly the same size.
Have you verified that assertion by running the script from the command
line or using view-source to see what is actually getting sent to the
browser? Maybe the pages only look like they contain the same amount of
text but the source includes other things you aren't seeing which are
being cumulatively added to the pages. Perhaps you're cumulatively
adding to a variable or a sticky field without realizing it.
> If someone's thinking "I've had that happen!"
No, sorry, I haven't. But I have only been using Perl to write HTML
pages since 1992, so my experience is limited. :-)
--
Jeff
------------------------------
Date: Thu, 05 Oct 2000 04:28:50 GMT
From: ewhite@ssc.wisc.edu (Eric White)
Subject: cgi script runs ok, but pages mysteriously get larger as it progresses
Message-Id: <8rgvil$mi2$1@news.doit.wisc.edu>
Ok, I've got a cgi script that's about 2mb in size. It generates a series of
forms and moves the user from page to page (about 40 in total). This is all
fine, for the most part, but I've discovered that as I go from page 3 to 4, 4
to 5, etc, the size of the next page (in kb - the actual number of bytes
passed back to the browser) seems to grow with each advancing page. This
isn't because the pages themselves get bigger; they're just text and all
roughly the same size.
I'm not even sure I've got a real question about this. I just thought I'd run
this by everyone before I start taking the code apart and putting it back
together tomorrow. (Today was lots of looking followed by more looking.)
If someone's thinking "I've had that happen!" and you'd like to point me in
the right direction, great. Or, if you'd just like to heckle, that's fine
too. :)
Did I mention that I've got another cgi script that's very similar to this one
that *doesn't* exhibit this behavior? Fun, fun, fun!
---------------------------------------------------------------
Eric White ewhite@ssc.wisc.edu
UW Survey Center phone: 608-265-4066
University of Wisconsin - Madison http://www.wisc.edu/uwsc/
------------------------------
Date: Thu, 05 Oct 2000 04:52:35 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: cgi script runs ok, but pages mysteriously get larger as it progresses
Message-Id: <nOTC5.17232$cW3.3424342@typhoon.southeast.rr.com>
Eric White <ewhite@ssc.wisc.edu> wrote in message
news:8rgvil$mi2$1@news.doit.wisc.edu...
> Ok, I've got a cgi script that's about 2mb in size. It generates a series
of
> forms and moves the user from page to page (about 40 in total). This is
all
> fine, for the most part, but I've discovered that as I go from page 3 to
4, 4
> to 5, etc, the size of the next page (in kb - the actual number of bytes
> passed back to the browser) seems to grow with each advancing page. This
> isn't because the pages themselves get bigger; they're just text and all
> roughly the same size.
[snip]
Could it be that with each new page, you're passing the answers from all the
previous forms in as hidden fields? Maintaining session information on the
client side?
------------------------------
Date: Thu, 05 Oct 2000 06:28:14 GMT
From: Rand25@juno.com
Subject: Re: CGI trouble
Message-Id: <8rh71s$eco$1@nnrp1.deja.com>
> ?? if it's working fine, then ???
> at what point does the problem come in ??
When I try to access cgi scripts (written in perl)
>
> Did a sample program or html file come with your setup ?
> So that, on execution, a menu of cgi programs comes up, to test
> your install ?
> If so, this will tell you if things are working or not.
Only a sample localhost page (when I load http://localhost this page
has a link to the manuals and says that if I see it that Apache is
setup and running)
> The exact error message is required !!
> By default, your root directory will look like :
> " http://localhost/4444/ "
> or something, but,
> will actually be :
> " http://localhost/4444/htdocs/ "
>
>
> You have to drop down to a DOS window to access it, just as normal.
> The Apache Server is a sort of shell, or emulator, running in the
> background, to execute perl and run your perl scripts.
> You don't actually access it, like a Unix or Linux shell.
> It's transparent.
>
> In your /cgi-bin/ place a small " hello.pl " script.
> On your browser's "Location Bar", that's this thing:
> == " http://localhost/4444/" ==
> have it read :
> " http://localhost/4444/cgi-bin/hello.pl "
> press enter.
>
> It should execute your hello.pl script.
> *(your "4444" may be different)
I do not have a 4444 its just http://localhost/whatever
> If not,,,, copy down the exact error message and re-post it here...
>
I did in previous posts, its error 500, and the post asking me to try
#!c:/perl/bin/perl.exe -w
solved my problem, I have a book that is written for ppl who have a
Unix web server (at work or for a server like Yahoo or Xoom/NBCi) and
want to write cgi scripts at home on a Windows computer.
> Steve
>
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 04:18:04 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: embedding in HTML
Message-Id: <0iTC5.16990$cW3.3406863@typhoon.southeast.rr.com>
N <g99z44@yahoo.com> wrote in message
news:stn1dnbhms328b@corp.supernews.com...
> Is there a way you embed perl script in the html files like PHP's <?php
....
> > method besides using SSI's? If it is too complicated an answer I would
be
> happy with the name of this function (if exists) so I could look it up.
>
> Thanks
>
> N
I recommend HTML::Mason.
hth,
p
------------------------------
Date: Thu, 05 Oct 2000 06:48:24 GMT
From: Rand25@juno.com
Subject: Re: Executing exe from webpage
Message-Id: <8rh87n$f6q$1@nnrp1.deja.com>
> This has nothing to do with CGI or perl.
> CGI is a communication method between browser and server application.
> Perl is a server script interpreter.
>
I was just asking if it was possible with a CGI script written with
Perl, and actually Perl is a full fledged programming language not just
an interpreter, it can make exe's (just in case you didn't know...).
>
> Actually, what you are trying to do is run a Dos/Windows "EXE"
> program, which resides on your local machine, from within your
> "Browser", either IE or Netscape.
Ummm, yup, thats what I'm trying to do, I just didn't say it in so many
words (I'm trying for an Ofuscated (sp?) post prize...)
>
> The Browser wasn't designed to act as a "shell" or platform in which
> to "run" or " launch " other applications.
> It would need to create another process to do that.
> Unless it's an actual Java program or VisualBasic "Plug-in" that works
> within the browser, it's not going to happen (gracefully).
Darn, but you don't know until you ask...
> There are tools out there to allow creating HTML menus to do what you
> want to do.
> These are "mini" offline browsers.
> Try "shareware.com" .
> Enter query "html tools" .or something like this.
Most of those take too long to download I was just trying for a Yes/No
and the basic idea ('eval menuItem1 + ".exe"' or something to that
effect, the menu I am using currently evaluates a bunch off html and
java into a link like: 'eval menuItem1 + ".url"' so that when you
click on the text, the browser treats it like a link to the url passed
to the function by the menuItem descriptor).
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 5 Oct 2000 05:19:20 +0100
From: "Phil Latio" <verybig@thebedroom.co.uk>
Subject: Formating output to be read in a form.
Message-Id: <8rgutp$jl3$1@neptunium.btinternet.com>
Hi
The below is part of the perl script to search a flatfile database and
display the results.
if ($Price){
print "$Price<BR>\n";}
However, I also want the values to be used in another script and I so I need
the script to produce the following output too.
<input type=hidden name="price" value="$Price">
How would this be written in perl ? The idea being the original is displayed
as before but the hidden fields are also placed within a form which reads
the newly added code when I press submit.
Cheers
Phil
------------------------------
Date: Wed, 04 Oct 2000 21:25:01 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Formating output to be read in a form.
Message-Id: <39DC029D.27565FA@vpservices.com>
Phil Latio wrote:
>
> <input type=hidden name="price" value="$Price">
>
> How would this be written in perl ?
print qq(
<input type="hidden" name="price" value="$Price">
);
OR
print <<EOH;
<input type="hidden" name="price" value="$Price">
EOH
OR
use CGI qw(:standard);
# ...
print hidden(
-name => "price",
-value => $Price
);
Note that it is not a mistake that there are quotes around $Price in the
first two examples and none in the last example. Also note that some
folks shudder when one uses a capitalized variable name and would prefer
to write it $price.
--
Jeff
------------------------------
Date: Thu, 05 Oct 2000 04:30:07 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Formating output to be read in a form.
Message-Id: <jtTC5.141$D4.190387200@news.frii.net>
In article <8rgutp$jl3$1@neptunium.btinternet.com>,
Phil Latio <verybig@thebedroom.co.uk> wrote:
>Hi
>
>The below is part of the perl script to search a flatfile database and
>display the results.
>
>if ($Price){
>print "$Price<BR>\n";}
>
>However, I also want the values to be used in another script and I so I need
>the script to produce the following output too.
>
><input type=hidden name="price" value="$Price">
>
>How would this be written in perl ? The idea being the original is displayed
>as before but the hidden fields are also placed within a form which reads
>the newly added code when I press submit.
>
>Cheers
>
Am I missing something? It sounds like you just described a solution
to your problem. Maybe you just need to accumulate the text of
the form in a variable and print it out later?
chris
--
This space intentionally left blank
------------------------------
Date: Thu, 05 Oct 2000 05:57:02 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Formating output to be read in a form.
Message-Id: <slrn8to612.1kv.mgjv@verbruggen.comdyn.com.au>
On Thu, 5 Oct 2000 05:19:20 +0100,
Phil Latio <verybig@thebedroom.co.uk> wrote:
Ooh.. what a clever name and email address. Did you have to think long
before you came up with that?
> The below is part of the perl script to search a flatfile database
> and display the results.
>
> if ($Price){ print "$Price<BR>\n";}
>
> However, I also want the values to be used in another script and I
> so I need the script to produce the following output too.
>
> <input type=hidden name="price" value="$Price">
>
> How would this be written in perl ? The idea being the original is
> displayed as before but the hidden fields are also placed within a
> form which reads the newly added code when I press submit.
What exactly is the problem? You know how to use print, as you show
above. So... Why don't you just use it?
print qq(<input type=hidden name="price" value="$Price">);
Now, please, if you want to program, learn to program. If you want to
program in Perl, familiarise yourself with Perl. Buy some good books,
learn to read the documentation.
Learn to type, at your shell prompt, commands starting with perldoc
# perldoc -f print
# perldoc perldoc
# perldoc perl
# perldoc perlfaq
# perldoc ModuleName
# perldoc -q keyword_to_find_in_the_FAQ
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, 05 Oct 2000 04:23:42 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: How to find IP address by MAC address?
Message-Id: <inTC5.137$D4.190387200@news.frii.net>
In article <vkMC5.45$l51.534@client>, JP <pangjo@hotmail.com> wrote:
>I am writing a Perl script which will check device status using SNMP
>functions. Since the IP addresses of the devices are dynamic, I would like
>to write the script based on the MAC or physical addresses.
>
>Can anyone tell me how I can convert an MAC address to IP using Perl?
>
>Thank you very much in advance.
>
>Joe
>
SNMP MIB includes an address translation table. You just need to
get two columns out of it. Ask your question in a group that has
SNMP somewhere in its name. Maybe someone there can give you the
details.
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Thu, 05 Oct 2000 05:15:21 GMT
From: leonardz <webmaster@cobnet.com>
Subject: Re: How? Read a file from another server?
Message-Id: <8rh2p7$b9l$1@nnrp1.deja.com>
> The point is that you should *ALWAYS* check the result of open, like
> this:
>
> open (DATAFILE, "<$FileName") or die "Couldn't open file: $!";
>
> There are many reasons why open could fail: the file might have been
> deleted by the Grim File Reaper, the disk might have gone bust, lpr
on
> fire :-)
>
Thanks very much for taking the time and effort to help me understand
this point. It is greatly appreciated.
leonardz
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 04:50:57 GMT
From: littlemanjohn@my-deja.com
Subject: LWP ->How to stop a redirect and work with cookies
Message-Id: <8rh1bg$acr$1@nnrp1.deja.com>
Is there an opposite to $ua->redirect_ok? I am trying to work cookies
of pages that have 301 and 302 redirects.
I've been trying various combinations using HTTP::Cookies and
LWP::UserAgent but can't get them to work together without being
redirected.
one of the many variations I've tried is below. Any help would be very
appreciated.
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Cookies;
my $ua = new LWP::UserAgent;
my $jar = HTTP::Cookies->new(file => "boo.txt", autosave => 1);
$r = "http://av.com";
$ua->agent ('Mozilla/4.0 (compatible; MSIE 5.0; MSN 2.5; Windows 98;
DigExt)\r\n');
$ua->timeout (100);
my $req = HTTP::Request->new(GET => "$r");
$jar->add_cookie_header($req);
my $response = $ua->simple_request($req);
$jar->extract_cookies($response);
print $response->as_string;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 04:24:04 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: multiple forms FAQ
Message-Id: <EnTC5.17034$cW3.3410437@typhoon.southeast.rr.com>
Pasquale <pdmos23@geocities.com> wrote in message
news:39DBF774.4AF407E@geocities.com...
> I'm sure I've seen this question in the FAQ's or the documentation
> somewhere, but I can't remember where. Can someone please tell me where
> it is or was I hallucinating?
> Thanks
> Pasquale
If this is a CGI form you're talking about, try perldoc CGI, then look for
"startform".
There's also an example script on Lincoln Stein's site at
http://stein.cshl.org/WWW/software/CGI/examples/multiple_forms.txt
hth,
p
------------------------------
Date: Wed, 4 Oct 2000 22:42:25 -0600
From: "Duke Normandin" <01031149@3web.net>
Subject: Re: Need the best Perl Tutorial -- bar none
Message-Id: <QBTC5.3355$Jd4.29354@jekyl.ab.tac.net>
Andrew J. Perrin wrote in message ...
>"Duke Normandin" <01031149@3web.net> writes:
>
>> This newbie is in dire need of the *best* Perl Tutorial
>> available on the 'net!! I've got close to a dozen
>> so-so ones already. Any suggestions?
>>
>> --
>> tia....duke
>>
>
>Personally, I'm looking for the fourth-best tutorial. Any advice?
http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html
-duke
------------------------------
Date: Thu, 05 Oct 2000 06:06:03 +0200
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: Net::SMTP problem
Message-Id: <39dbfe2b.524144494f47414741@radiogaga.harz.de>
jason (elephant@squirrelgroup.com) wrote:
: Alex Harvey wrote ..
: >I am finding that when I use Net::SMTP to send a simple email to myself I
: >receive an error "The system cannot find the path specified". (I am using
: >Windows 2000.)
...
: > $smtp = Net::SMTP->new('mail.pacificgaming.com.au');
...
: >c:\perl> perl -w sendmail_eg.pl
: >
: >The system cannot find the path specified.
: >Use of uninitialized value in scalar assignment at
: > C:/Perl/site/lib/Net/Domain.pm line 191 (#1)
:
: this happens because the Net modules have been unable to determine your
: domain name .. if you know what your domain name is then you can set
: either the LOCALDOMAIN or the DOMAIN environment variable on your
: machine
... or just supply your local mail domain name to Net::SMTP::new via the
`hello' option.
cu,
Martin
--
One OS to rule them all | Martin Vorlaender | VMS & WNT programmer
One OS to find them | work: mv@pdv-systeme.de
One OS to bring them all | http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de
------------------------------
Date: Thu, 05 Oct 2000 06:19:21 GMT
From: Rand25@juno.com
Subject: Re: OT: Re: CGI trouble
Message-Id: <8rh6h6$e0d$1@nnrp1.deja.com>
It worked, turns out I tried every shebang line except the right
one....I tried every variation I could think of....but the one you
suggested worked.
THANKS!!!!
All the books say to just point to the directory, but for me I have to
include the exe too, I did not know that.
Thanks for your help
John
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 05:40:36 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: printing a postscript file directly
Message-Id: <8rh48k$cdj$1@nnrp1.deja.com>
In article <8rfgld$ad$1@nnrp1.deja.com>,
joseph7971@my-deja.com wrote:
> Hi,
> I am trying to find out how to send a postscript file directly to a
> printer from within a Perl program, especially for windows 95
operating
> system. I have looked through older messages but I can't seem to find
> exactly what I'm looking for. All help is appreciated,
> Thanks in advance,
> Joe Timoney
If your printer is a postscript printer, you
could simply copy the postscript file to the
printer (PRN, LTP1, \\servername\printer, whatever).
Brendon
++++
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 07:03:40 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Searching for spaces in a string only getting the beginning of the string
Message-Id: <slrn8toab6.5lk.rgarciasuarez@rafael.kazibao.net>
Ron Hill wrote in comp.lang.perl.misc:
>Hello All,
>I am trying to count the number of spaces in a string.
A fast way to do this is to use tr/// :
my $count = $string =~ tr/ / /;
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 4 Oct 2000 23:31:03 +1100
From: "Kiel Stirling" <taboo@comcen.com.au>
Subject: Re: ssh and vnc on nt via perl
Message-Id: <39db2307$1@nexus.comcen.com.au>
Todd Seidenberg <skippy@rhubarb.syt.org> wrote:
>Hi,>
>
>I am currently trying to write a perl script on NT to do the following:
>
>
>start a secure session between my NT machine and a Solaris machine, Forward remote port 5902 to local port 5902, and run a vncviewer process on my NT (local) machine against my forwarded port.
>
>
>I currently have the following:
>
>##########
>#########################################
># #
># Securely launch a VNC session #
># #
>#########################################
>
>
>####
>#Do the secure remote port forwarding thingy.
>####
>unless (system("ssh -v -C -L 5902:unix_box:5902 unix_box -l username &") ) {
>
> print "Forwarded the Port!\nNow Run the VNC thingy\n";
>}
>
>####
># Run the vncviewer on the forwarded port...duh
>####
>system("vncviewer ");
>
>######################
>
>Unfortunately, this doesn't work quite the way I want it to.
>
>I do get as far as the ssh command, and I can log into the machine, however, once the vncviewer process runs, the port is no longer forward. Essentially, I can't figure out a way to execute the ssh command and execute the vncviewer command while the ssh is in the middle of a session. I need to do this, because thats the only way to keep the port forwarded. NT doesn't support the -f 'forking' feature of ssh, either. So actually, I have no idea what to do.
>
>Any help would be greatly appreciated,
>
>
>Thanks,
>
>Todd
>
>
I do this via 2 scripts. One on each host.
__1st host script_____
#!/usr/bin/perl
use strict;
my $buffer="I made it!!";
system "ssh hostname.com: /path/to/script/to/run.PL $buffer";
___2nd host script ____
#!/usr/bin/perl
use strict;
my $buffer = $ARGV[0];
print `hostname`,"\n$buffer\n";
Hope that helps
Regards,
Kiel Stirling
------------------------------
Date: 5 Oct 2000 04:46:38 GMT
From: Gabriel Millerd <millerd@ns1.rli-net.net>
Subject: Re: SSI in a CGI
Message-Id: <8rh13e$b43$1@news.powerisp.com>
Dave O'Brien <david.obrien@ssmb.com.au> wrote:
> The problem is that the file has to be set to be options include in the
> Apache setup (httpd.conf), and when you do that, it parses the perl
> script :( What you could do is get perl to completely generate the html
> file with include tags, and save to a location on the web server which
> has includes enables, then get perl to redirect to the new page. A bit
> nasty I know. If you receive a better soloution, let us know.
man Apache::OutputChain
<Files *.pl>
PerlSendHeader On
SetHandler perl-script
PerlHandler Apache::OutputChain Apache::SSIChain Apache::Registry
Options ExecCGI
</Files>
---
Gabriel Millerd |
Plumber | Let him who desires peace prepare for war.
http://qualhost.com| -Vegetius, De Rei Militari
QualHost, LLC |
------------------------------
Date: Thu, 05 Oct 2000 04:07:04 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Threads and SMP
Message-Id: <I7TC5.16910$cW3.3399643@typhoon.southeast.rr.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn8tngns.3ki.tjla@thislove.dyndns.org...
> I was shocked! How could Louis Z <louis@trapezoid.com>
> say such a terrible thing:
> >Is there any way for Perl to take advantage of dual CPUs? Using threads?
> >Ideally, I'd be able to run some simulation programs twice as fast if
they
> >could' use both CPUs. Thanks.
>
> perldoc -f fork
How will fork() assist with spreading workload across processors? For some
reason, I have assumed for a while now that explicitly using one processor
for one thing and another for something else required threads.
tia,
p
------------------------------
Date: Thu, 05 Oct 2000 06:00:50 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Threads and SMP
Message-Id: <slrn8to686.1kv.mgjv@verbruggen.comdyn.com.au>
On Thu, 05 Oct 2000 04:07:04 GMT,
Philip Garrett <philipg@atl.mediaone.net> wrote:
>
> How will fork() assist with spreading workload across processors? For some
> reason, I have assumed for a while now that explicitly using one processor
> for one thing and another for something else required threads.
Not at all. two separate processes will be scheduled on different CPUs
by the OS (hopefully).
Image a process that needs to read some heavily compressed data, and
do some serious munging on it. It could spawn a child, which
uncompresses the data, spits it out to STDOUT, where the parent reads
it, and does its manipulation. One process decompresses (using one
CPU), the other munges (using another one). This is a very common
thing to do.
# perldoc perlipc
You should never _explicitly_ try to use one or the other CPU, unless
you really, really know what you're doing. Leave it up to the OS to do
the scheduling for you. That's what OS's are for. Either use threads
or multiple processes, but don't schedule anything yourself.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing
Interactive Media Division | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd. | later I can ask him what he meant -
NSW, Australia | Steven Wright
------------------------------
Date: Thu, 5 Oct 2000 15:40:30 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: timeout on user input on NT
Message-Id: <MPG.1446bf562168879f9897fc@localhost>
Alex Tang wrote ..
>Is it possible to timeout on user input using Perl on NT (command line)?
>
>What I'm trying to do is have the user input some data. If after a
>certain period of time (10 seconds for now), the user doesn't enter any
>data, I want the program to continue on its way.
>
>is this possible?
you could use Term::ReadKey to grab each key as it's typed .. and then
be checking a timer for periods where you're receiving nothing .. the
following (very short) example should demonstrate the usage (it has a
two second timeout)
#!/usr/bin/perl -w
use strict;
my $timeout = 2;
use Term::ReadKey;
ReadMode 1;
my $test_time = time + $timeout;
my $key = my $string = '';
KEY_CHECK: until( $key eq "\cD" )
{
while( not defined ( $key = ReadKey(-1)))
{
if( $test_time < time)
{
print "\n\nTimed out\n";
last KEY_CHECK;
}
next;
}
print $key;
# got a key - reset timer
$test_time = time + $timeout;
$string .= $key;
}
ReadMode 0;
print "\nReceived: [$string]\n";
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
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 4526
**************************************