[31006] in Perl-Users-Digest
Perl-Users Digest, Issue: 2251 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 06:09:41 2009
Date: Thu, 5 Mar 2009 03:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 5 Mar 2009 Volume: 11 Number: 2251
Today's topics:
Re: calculate an average with every data in an array <maustin@firstdbasource.com>
Re: calculate an average with every data in an array <unclebob@tnglwood.demon.co.uk>
Re: calculate an average with every data in an array <burner+usenet@imf.au.dk>
Re: CGI query string encoding issue... <howachen@gmail.com>
Re: CGI query string encoding issue... <noreply@gunnar.cc>
new CPAN modules on Thu Mar 5 2009 (Randal Schwartz)
perl/postscript csv label maker <mijoryx@yahoo.com>
Polling a file without using huge amount of system reso <stahl.karl@gmail.com>
Re: Polling a file without using huge amount of system <ben@morrow.me.uk>
Re: Polling a file without using huge amount of system <stahl.karl@gmail.com>
Re: Polling a file without using huge amount of system <syscjm@sumire.gwu.edu>
Re: system not returning correct return code. <whynot@pozharski.name>
Re: Telnet and then SSH <maustin@firstdbasource.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Mar 2009 17:18:35 -0600
From: Michael Austin <maustin@firstdbasource.com>
Subject: Re: calculate an average with every data in an array
Message-Id: <i1Erl.8779$%54.21@nlpi070.nbdc.sbc.com>
Erol Akman wrote:
> Hi,
>
> I have following (crazy) task and was hoping to solve it via perl, but
> I need your help, please.
>
> I have an array of values and need to calculate every possible average
> and sort it by the average data:
>
> @array = qw(4 6 2 7 1 8 3 5 9 10);
>
>
> This should be printed out:
> 4+2 = 6, Average =3
> 4+6+2 = 12, Average=4
> 4+6 = 10, Average=5
> ...
> 10+4+6+2+3 = 25, Average=5
>
> also nice to have, but not must have: I need to see which scalar perl
> used to sum up, maybe "4+6+2 = 12, Average=4, scalar 0,1,3 were summed
> up"
>
> I know, its nuts, but I really need this.
>
> Background: I have lots and lots of data like 23.33, 12.25, 84.56 and
> so on and hundreds of values like 54, 32, 45. I don't know which and
> how many of these values where summed up to get the data above. My
> idea was to calculate every possible average to find out which values
> where summed up and averaged out.
>
> Is this possible? Can you help me?
>
> Best regards
> Erol
possible? yes.
practical? NO.
useful? I doubt it.
complete in your lifetime? doubtful.
getting the CORRECT permutation? throw a dart.
------------------------------
Date: Thu, 05 Mar 2009 08:35:33 +0000
From: Robert Billing <unclebob@tnglwood.demon.co.uk>
Subject: Re: calculate an average with every data in an array
Message-Id: <p9Mrl.27907$q45.5092@newsfe07.ams2>
Erol Akman wrote:
> Background: I have lots and lots of data like 23.33, 12.25, 84.56 and
> so on and hundreds of values like 54, 32, 45. I don't know which and
> how many of these values where summed up to get the data above. My
> idea was to calculate every possible average to find out which values
> where summed up and averaged out.
>
> Is this possible? Can you help me?
At first sight this does not look possible because the brute force
attack, simply trying all the possibilities, requires something like
10^30 iterations. However it does remind me of a digital filter
optimisation problem that two of us did solve over one long summer with
a VAX and a Transputer array (remember those?). The final version could
find optimal integer settings for a very large filter in about 4 hours
of solid bash on the array.
The trick was to make a first guess, then decide which direction would
take us closer to what we wanted, effectively deciding which way was
uphill. Having found a hilltop we then tried making a grid of jumps
around the neighbourhood to see if we could find a higher hill, then
climb that, and so on until we reached a point where every change made
the filter worse.
It seems to me that every entry in your raw data is either above or
below the value you want, so you need to find a selection of above and
below values which pull the average in both directions with equal
weight. Some sort of "put this in and take that out" iteration might
well converge in a reasonable time.
------------------------------
Date: Thu, 05 Mar 2009 10:56:06 +0100
From: Rasmus Villemoes <burner+usenet@imf.au.dk>
Subject: Re: calculate an average with every data in an array
Message-Id: <u0l1vtc70p5.fsf@orc10.imf.au.dk>
Robert Billing <unclebob@tnglwood.demon.co.uk> writes:
> Erol Akman wrote:
>
>> Background: I have lots and lots of data like 23.33, 12.25, 84.56 and
>> so on and hundreds of values like 54, 32, 45. I don't know which and
>
> It seems to me that every entry in your raw data is either above or
> below the value you want, so you need to find a selection of above and
> below values which pull the average in both directions with equal
> weight. Some sort of "put this in and take that out" iteration might
> well converge in a reasonable time.
Yes, the OP definitely must use some fancier algorithm than brute
force to achieve his goal. An obvious observation is that the average
of some integers is a rational number. 23.33 looks suspicially like it
is really 23 + 1/3 = 70/3, so one could limit the search to (3
integers summing to 70) or (6 integers summing to 140) or (9 integers
summing to 210) or ... I don't know if there are standard algorithms
to search for solutions for each problem in ().
This approach of course assumes he knows the floating point data with
sufficient precision to make an educated guess at the true rational
representation (is 84.56 really 84 + 5/9, etc?).
Also, it is still unclear if he wants all subsets with a given average
or just one.
--
Rasmus Villemoes
<http://rasmusvillemoes.dk/>
------------------------------
Date: Wed, 4 Mar 2009 19:49:32 -0800 (PST)
From: howa <howachen@gmail.com>
Subject: Re: CGI query string encoding issue...
Message-Id: <5d034469-716d-44d3-8707-98e6988c0010@40g2000prx.googlegroups.com>
Hi,
On Mar 4, 11:41 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote:
> Not really, because there's no way to look at an arbitrary bit string and
> know that it's BIG5, or utf8, or whatever. You said parameter s is a BIG5
> string in the second case--but it's also a utf8 string: "^[$BCfJ8^[(B".
>
A simpler example, using encoded string, for the url:
http://www.example.com/cgi-bin/test.cgi?s=中
http://www.example.com/cgi-bin/test.cgi?s=%A4%A4 (BIG-5, 0xa440 to
0xc67e, http://en.wikipedia.org/wiki/Big5)
http://www.example.com/cgi-bin/test.cgi?s=%E4%B8%AD (UTF-8, see
variable $valid_utf8_regexp at http://cpansearch.perl.org/src/MARKF/Test-utf8-0.02/lib/Test/utf8.pm)
As you can see, BIG5 char %A4%A4 is definitely out of UTF8 range but
utf8::valid() return 1
------------------------------
Date: Thu, 05 Mar 2009 10:03:49 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI query string encoding issue...
Message-Id: <719io8Fk8f21U1@mid.individual.net>
howa wrote:
> Hello, consider my simple cgi program below:
>
> #=======
> #!/usr/bin/perl
> use strict;
>
> use CGI;
> my $q = new CGI;
> my $s = $q->param("s");
> print $q->header( -type => "text/html" );
>
> print utf8::valid ($s);
> #=======
>
> Then I call, e.g.
>
> http://www.example.com/cgi-bin/test.cgi?s=abc (print 1, ok)
> http://www.example.com/cgi-bin/test.cgi?s=中文 (also print 1, but my
> paramater s is BIG5 traditional Chinese encoding, not utf8!)
I'm not sure about the meaning of utf8::valid (), but the docs
recommends the use of utf8::is_utf8().
Does the below code make sense to you?
$ cat test.pl
use Encode;
$big5_uriencoded = '%A4%A4';
( $big5_bytes = $big5_uriencoded ) =~ s/%(..)/chr(hex $1)/eg;
print '$big5_bytes ', utf8::is_utf8($big5_bytes) ? 'is' : 'is not',
" in UTF-8 internally.\n";
$string = decode('Big5', $big5_bytes);
print '$string ', utf8::is_utf8($string) ? 'is' : 'is not',
" in UTF-8 internally.\n\n";
$ perl test.pl
$big5_bytes is not in UTF-8 internally.
$string is in UTF-8 internally.
I believe it tells us that it's not possible to encode $big5_bytes
directly to UTF-8, while that's possible with $string.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 5 Mar 2009 05:42:25 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Mar 5 2009
Message-Id: <KG0qIp.oqp@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
AProf-0.4
http://search.cpan.org/~unera/AProf-0.4/
is a profiler for periodically running processes
----
AProf-0.5
http://search.cpan.org/~unera/AProf-0.5/
is a profiler for periodically running processes
----
Apache-AuthTkt-2.1
http://search.cpan.org/~gavinc/Apache-AuthTkt-2.1/
module to generate authentication tickets for mod_auth_tkt apache module.
----
Apache2-ASP-2.33
http://search.cpan.org/~johnd/Apache2-ASP-2.33/
ASP for Perl, reloaded.
----
Apache2-ASP-2.34
http://search.cpan.org/~johnd/Apache2-ASP-2.34/
ASP for Perl, reloaded.
----
App-Cpan-1.56_04
http://search.cpan.org/~bdfoy/App-Cpan-1.56_04/
easily interact with CPAN from the command line
----
App-Framework-0.04
http://search.cpan.org/~sdprice/App-Framework-0.04/
A framework for creating applications
----
App-Framework-0.05
http://search.cpan.org/~sdprice/App-Framework-0.05/
A framework for creating applications
----
App-ZofCMS-Plugin-FileUpload-0.0112
http://search.cpan.org/~zoffix/App-ZofCMS-Plugin-FileUpload-0.0112/
ZofCMS plugin to handle file uploads
----
Archive-RPM-0.03
http://search.cpan.org/~rsrchboy/Archive-RPM-0.03/
work with an RPM
----
Bio-Phylo-0.17_RC9
http://search.cpan.org/~rvosa/Bio-Phylo-0.17_RC9/
Phylogenetic analysis using perl
----
Bot-BasicBot-Pluggable-0.60
http://search.cpan.org/~tomi/Bot-BasicBot-Pluggable-0.60/
extended simple IRC bot for pluggable modules
----
CGI-IDS-1.0111
http://search.cpan.org/~hinnerk/CGI-IDS-1.0111/
PerlIDS - Perl Website Intrusion Detection System (XSS, CSRF, SQLI, LFI etc.)
----
Catalyst-Plugin-Server-JSONRPC-0.05
http://search.cpan.org/~darknos/Catalyst-Plugin-Server-JSONRPC-0.05/
Catalyst JSONRPC Server Plugin
----
Class-Monadic-0.03
http://search.cpan.org/~gfuji/Class-Monadic-0.03/
Provides monadic methods (a.k.a. singleton methods)
----
ClearPress-323
http://search.cpan.org/~rpettett/ClearPress-323/
Simple, fresh & fruity MVC framework - http://clearpress.net/
----
DateTime-Format-Natural-0.75_03
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.75_03/
Create machine readable date/time with natural parsing logic
----
File-Lockfile-1.0.2
http://search.cpan.org/~glorybox/File-Lockfile-1.0.2/
create lockfile to prevent process simultaneous run
----
IO-CaptureOutput-1.1101
http://search.cpan.org/~dagolden/IO-CaptureOutput-1.1101/
capture STDOUT and STDERR from Perl code, subprocesses or XS
----
Log-Dispatch-SNMP-0.01
http://search.cpan.org/~garu/Log-Dispatch-SNMP-0.01/
Object for logging to SNMP servers
----
Log-Simple-Color-0.0.2
http://search.cpan.org/~keedi/Log-Simple-Color-0.0.2/
Log messages with different color for console
----
Math-Symbolic-0.603
http://search.cpan.org/~smueller/Math-Symbolic-0.603/
Symbolic calculations
----
Math-SymbolicX-ParserExtensionFactory-3.02
http://search.cpan.org/~smueller/Math-SymbolicX-ParserExtensionFactory-3.02/
Generate parser extensions
----
Mozilla-DOM-ComputedStyle-0.04
http://search.cpan.org/~bosu/Mozilla-DOM-ComputedStyle-0.04/
Interface to Mozilla getComputedStyle function.
----
Mozilla-Mechanize-GUITester-0.18
http://search.cpan.org/~bosu/Mozilla-Mechanize-GUITester-0.18/
enhances Mozilla::Mechanize with GUI testing.
----
Net-Amazon-S3-Tools-0.08
http://search.cpan.org/~mra/Net-Amazon-S3-Tools-0.08/
command line tools for Amazon S3
----
Net-Connection-Sniffer-0.29
http://search.cpan.org/~miker/Net-Connection-Sniffer-0.29/
gather stats on network connections
----
Net-Z3950-SimpleServer-1.11
http://search.cpan.org/~mirk/Net-Z3950-SimpleServer-1.11/
Simple Perl API for building Z39.50 servers.
----
PDL-NetCDF-0.94
http://search.cpan.org/~dhunt/PDL-NetCDF-0.94/
Object-oriented interface between NetCDF files and PDL objects.
----
POE-Component-IRC-6.00
http://search.cpan.org/~bingos/POE-Component-IRC-6.00/
A fully event-driven IRC client module
----
POE-Component-Pluggable-1.16
http://search.cpan.org/~bingos/POE-Component-Pluggable-1.16/
A base class for creating plugin enabled POE Components.
----
POE-Declare-0.06
http://search.cpan.org/~adamk/POE-Declare-0.06/
A POE abstraction layer for conciseness and simplicity
----
POE-Declare-0.07
http://search.cpan.org/~adamk/POE-Declare-0.07/
A POE abstraction layer for conciseness and simplicity
----
Padre-0.28
http://search.cpan.org/~szabgab/Padre-0.28/
Perl Application Development and Refactoring Environment
----
Paranoid-0.21
http://search.cpan.org/~corliss/Paranoid-0.21/
Paranoia support for safer programs
----
Parse-Method-Signatures-1.003001
http://search.cpan.org/~ash/Parse-Method-Signatures-1.003001/
Perl6 like method signature parser
----
Path-Extended-0.06
http://search.cpan.org/~ishigaki/Path-Extended-0.06/
yet another Path class
----
Pod-POM-View-DocBook-0.05
http://search.cpan.org/~andrewf/Pod-POM-View-DocBook-0.05/
DocBook XML view of a Pod Object Model
----
Provision-Unix-0.46
http://search.cpan.org/~msimerson/Provision-Unix-0.46/
provision accounts on unix systems
----
RTPG-0.1
http://search.cpan.org/~unera/RTPG-0.1/
is a module for accessing to rtorrent's SCGI functions.
----
RTPG-0.1.1
http://search.cpan.org/~unera/RTPG-0.1.1/
is a module for accessing to rtorrent's SCGI functions.
----
RTPG-0.2.0
http://search.cpan.org/~unera/RTPG-0.2.0/
is a module for accessing to rtorrent's SCGI functions.
----
Rose-DB-Object-0.780
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.780/
Extensible, high performance object-relational mapper (ORM).
----
Simo-0.09_05
http://search.cpan.org/~kimoto/Simo-0.09_05/
Very simple framework for Object Oriented Perl.
----
Simo-0.1001
http://search.cpan.org/~kimoto/Simo-0.1001/
Very simple framework for Object Oriented Perl.
----
Sys-Info-0.69_01
http://search.cpan.org/~burak/Sys-Info-0.69_01/
Fetch information from the host system
----
Sys-Info-Base-0.69_01
http://search.cpan.org/~burak/Sys-Info-Base-0.69_01/
Base class for Sys::Info
----
Sys-Info-Base-0.69_02
http://search.cpan.org/~burak/Sys-Info-Base-0.69_02/
Base class for Sys::Info
----
Sys-Info-Driver-Linux-0.69_01
http://search.cpan.org/~burak/Sys-Info-Driver-Linux-0.69_01/
Linux driver for Sys::Info
----
Sys-Info-Driver-Unknown-0.69_01
http://search.cpan.org/~burak/Sys-Info-Driver-Unknown-0.69_01/
Compatibility layer for Sys::Info
----
Sys-Info-Driver-Windows-0.69_01
http://search.cpan.org/~burak/Sys-Info-Driver-Windows-0.69_01/
Windows driver for Sys::Info
----
Sys-Info-Driver-Windows-0.69_02
http://search.cpan.org/~burak/Sys-Info-Driver-Windows-0.69_02/
Windows driver for Sys::Info
----
Task-Sites-ShlomiFish-0.0202
http://search.cpan.org/~shlomif/Task-Sites-ShlomiFish-0.0202/
Specifications for modules needed for building www.shlomifish.org , whose sources are publically available, and serve as examples for several technologies.
----
Term-Sprog-0.04
http://search.cpan.org/~keichner/Term-Sprog-0.04/
Perl extension for displaying a progress indicator on a terminal.
----
Test-LeakTrace-0.07
http://search.cpan.org/~gfuji/Test-LeakTrace-0.07/
Traces memory leaks
----
Test-WWW-Selenium-Catalyst-0.03
http://search.cpan.org/~ash/Test-WWW-Selenium-Catalyst-0.03/
Test your Catalyst application with Selenium
----
WWW-UserAgent-Random-0.01
http://search.cpan.org/~mcantoni/WWW-UserAgent-Random-0.01/
Perl extension to generate random User Agent
----
WebService-Validator-HTML-W3C-Embedded-0.01
http://search.cpan.org/~ddick/WebService-Validator-HTML-W3C-Embedded-0.01/
Access the W3Cs online HTML validator in a local persistent daemon
----
Win32-IEAutomation-RapidShare-0.02
http://search.cpan.org/~kxj/Win32-IEAutomation-RapidShare-0.02/
Perl extension for downloading files hosted by RapidShare
----
XML-Grammar-Fortune-0.0108
http://search.cpan.org/~shlomif/XML-Grammar-Fortune-0.0108/
convert the FortunesXML grammar to other formats and from plaintext.
----
XML-Grammar-Screenplay-0.0502
http://search.cpan.org/~shlomif/XML-Grammar-Screenplay-0.0502/
CPAN distribution implementing an XML grammar for screenplays.
----
ZConf-BGSet-GUI-GTK-0.0.1
http://search.cpan.org/~vvelox/ZConf-BGSet-GUI-GTK-0.0.1/
GTK GUI for ZConf::BGSet
----
ZConf-Mail-0.3.0
http://search.cpan.org/~vvelox/ZConf-Mail-0.3.0/
Misc mail client functions backed by ZConf.
----
Zucchini-0.0.13
http://search.cpan.org/~chisel/Zucchini-0.0.13/
turn templates into static websites
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Wed, 4 Mar 2009 22:15:59 -0800 (PST)
From: luser-ex-troll <mijoryx@yahoo.com>
Subject: perl/postscript csv label maker
Message-Id: <e8e73e53-016c-4362-b16a-f5f09a6b394e@r34g2000vbp.googlegroups.com>
Has this already been done better?
Surely this idea isn't new?
This is a project for my mom, for whom
MSWord and Excel no longer play nicely together.
-- luser-ex-troll
#!/usr/bin/perl
# labels.pl reads csv records in the form:
# "Name","123 Street","Apt","City, ST ZIP"
# from a file named "addr.csv" and
# produces a postscript program on stdout
# suitable for piping into ps2pdf or
# even distiller, maybe
# CAVEATS: prototype produces at most
# one page. label and sheet sizes are hard-coded
# at 3 3-inch-width labels which are 4*17 points
# high. I don't have any real ones on hand
# to measure.
$IN = "addr.csv";
open IN or die "Can't open input: $!";
print <<PROLOG;
%!
/in{72 mul}def
/LEAD 17 def
/LM 10 def
/count 0 def
/TM 11 in LEAD sub def
/Palatino-Roman 15 selectfont
[
PROLOG
while(<IN>) {
s/\n$//;
s/^"/\[\(/;
s/","/\)\(/g;
s/"$/\)\]/;
s/$/\n/;
print;
}
print <<PSPROGRAM;
]
{ %each record
LM TM moveto
{ %each address line
dup () eq { pop } { % skip empties
show % paint the string
%currentpoint exch = = = % diagnostic
LM currentpoint exch pop LEAD sub moveto % reposition
} ifelse
} forall
/LM LM 3 in add store % move over
/count count 1 add store
count 3 mod 0 eq { % back to left after each 3
/LM 10 store /TM TM LEAD 4 mul sub store
} if
} forall
showpage
PSPROGRAM
------------------------------
Date: Wed, 4 Mar 2009 15:48:03 -0800 (PST)
From: Ishmael <stahl.karl@gmail.com>
Subject: Polling a file without using huge amount of system resources
Message-Id: <6efce7f9-9da5-46ca-895d-86aa1e560160@v13g2000pro.googlegroups.com>
I would like to check a file continuously to see if something has been
written to it. If so, immediately run a script. I can do this
successfully by repeatedly polling the file, as shown below, but this
uses up lots of system resources. I can, of course, add a 'sleep' to
the while loop, which reduces the drag on the system, but it also
slows down the response time.
Can someone recommend a replacement for this code using some more
elegant means? Ideally, I would like to set some sort of interrupt as
soon as the \n character is written to the file. That way, I can
avoid doing any polling myself and let the system handle it. Maybe
select(2) or FIFOs would work, but I've read the documentation and
can't figure out if this is really what I want. Thanks for your help!
# ---- My naive way ----
# Listener
open(FID, ">myfile") || die("Can't open: $!");
while (1) {
if (my $line = <FID>) {
print "$line\n";
last;
}
}
# Writer
open(FID, ">myfile") || die("Can't open: $!");
print FID "test\n";
------------------------------
Date: Thu, 5 Mar 2009 01:18:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Polling a file without using huge amount of system resources
Message-Id: <7sl386-g17.ln1@osiris.mauzo.dyndns.org>
Quoth Ishmael <stahl.karl@gmail.com>:
> I would like to check a file continuously to see if something has been
> written to it. If so, immediately run a script. I can do this
> successfully by repeatedly polling the file, as shown below, but this
> uses up lots of system resources. I can, of course, add a 'sleep' to
> the while loop, which reduces the drag on the system, but it also
> slows down the response time.
Running round a tight loop like that is always a bad idea. If polling is
the only answer, then you need a sleep in there. Even only one second
will make a big difference to the load on the system.
For a more elegant solution, you will have to use something
system-specific, since there isn't any standard way of doing this. Since
you haven't told us what OS you are on, I can't tell what you might be
able to use, but some of the available mechanisms are:
fam, which works on many Unix systems, and will fall back to polling
(sanely) if there is no kernel support it can make use of. The GNU
implementation called 'gamin' is generally better than the original
SGI implementation.
inotify or dnotify on Linux, depending on kernel version.
kqueue on the BSDs.
Win32::ChangeNotify on Win32.
Most of these have modules on CPAN, and there may well be others I don't
know about. Check your system documentation.
> Can someone recommend a replacement for this code using some more
> elegant means? Ideally, I would like to set some sort of interrupt as
> soon as the \n character is written to the file. That way, I can
> avoid doing any polling myself and let the system handle it. Maybe
> select(2) or FIFOs would work, but I've read the documentation and
> can't figure out if this is really what I want. Thanks for your help!
If you just want to send some data from one process to another, and you
don't need it in a file, then a fifo is exactly what you want. See
"Named Pipes" in perldoc perlipc.
Ben
------------------------------
Date: Wed, 4 Mar 2009 19:05:01 -0800 (PST)
From: Ishmael <stahl.karl@gmail.com>
Subject: Re: Polling a file without using huge amount of system resources
Message-Id: <526b167f-45a9-429a-9a26-0bfc21c5ac07@y38g2000prg.googlegroups.com>
Thanks for the response, that's quite helpful! As it turns out, FIFOs
do the trick for what I wanted. But now I'm curious - when I open,
for example, an xterm window, it will wait patiently until I type
something, and it knows (instantly!) when I press 'Enter'. That means
that somewhere, it is polling rapidly for keypress events, yet it uses
essentially no system resources. Do you know if that is implemented
using the functions you describe (like inotify?)? Or is there some
other secret mechanism?
------------------------------
Date: Thu, 05 Mar 2009 04:17:57 -0600
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: Polling a file without using huge amount of system resources
Message-Id: <slrngqv9ml.i6m.syscjm@sumire.gwu.edu>
On 2009-03-05, Ishmael <stahl.karl@gmail.com> wrote:
> Thanks for the response, that's quite helpful! As it turns out, FIFOs
> do the trick for what I wanted. But now I'm curious - when I open,
> for example, an xterm window, it will wait patiently until I type
> something, and it knows (instantly!) when I press 'Enter'. That means
> that somewhere, it is polling rapidly for keypress events, yet it uses
No, it doesn't. It means that the operating system knows it's been waiting
for a keypress and wakes it up when the keypress is made. This is done by
means of interrupts, not polling.
> essentially no system resources. Do you know if that is implemented
> using the functions you describe (like inotify?)? Or is there some
> other secret mechanism?
You have to have OS support for the event you're waiting for.
--
Christopher Mattern
NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities
------------------------------
Date: Thu, 05 Mar 2009 04:14:14 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: system not returning correct return code.
Message-Id: <slrngqudbq.dek.whynot@orphan.zombinet>
On 2009-03-04, Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> Eric Pozharski wrote:
>> On 2009-03-03, Ben Morrow <ben@morrow.me.uk> wrote:
>>> Quoth omi <oakulkarni@gmail.com>:
>>>> On Mar 3, 9:14 pm, omi <oakulka...@gmail.com> wrote:
>>>>> Please see following snip of the code:
>>>>>
>>>>> $SIG{CHLD} = 'IGNORE';
>>>>>
>>>>> my $ret1 = `ls jjsjds`;
>>>>> my $ret = $?;
>>>>>
>>>>> If we see the value of return code, that is not correctly set.
>>>>> and this problem is coming because of the "$SIG{CHLD} = 'IGNORE';"
>>>>> flag is set.
>>> Yes. From the $? entry in perldoc perlvar:
>>>
>>> If you have installed a signal handler for "SIGCHLD", the value
>>> of $? will usually be wrong outside that handler.
>>>
>>> On systems that honour "IGNORE" for SIGCHLD, it counts as a signal
>>> handler. So don't do that.
>>
>> I would like that quote to be verified.
>
> Which aspect?
"If you have ... that handler."
>> Look, right now I have a big
>> deal of coding (testing mostly) about childs, pipes, etc. While
>> experimenting I've set C<$SIG{CHLD} = sub { warn $? }>. And I was
>> surprised to see C<0> as the inside value. I<$?> is set, and has proper
>> value, but only after B<waitpid>. Wouldn't like some kind perlist with
>> deeper insight comment on this?
>
> $? is only set after the thing that sets it, yes. Being inside the
> handler doesn't automatically cause $? to get set, it just means that
> the sig handler that you are already in won't get in the way of it being
> set, like it would if a sig handler exists but were you not in the sig
> handler. (Which is not to say that other things couldn't get in the way
> of $? being set correctly when inside a sig handler, just not the sig
> handle itself.)
(that seems my english is a way bad still) Did I got that right? The
perldoc wants to say that even if I'm in B<waitpid> and I get SIGCHLD
then the I<$?> still would be unset?
p.s. Look, I can experimentally get what's going on, I just want to get
what perldoc wants to say.
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Wed, 04 Mar 2009 16:18:09 -0600
From: Michael Austin <maustin@firstdbasource.com>
Subject: Re: Telnet and then SSH
Message-Id: <P5Drl.2893$Lr6.1611@flpi143.ffdc.sbc.com>
Ben Morrow wrote:
> Quoth "friend.05@gmail.com" <hirenshah.05@gmail.com>:
>> From Server 1 I have to Telnet to Server 2 . I can also ftp. So that
>> won't be problem.
>>
>>
>> Sample Code: Not sure just trying this one
>>
>> use Net::Telnet;
>> use Net::SSH::Perl;
>>
>> #telnet to Server 2
>>
>> $telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
>> $telnet->open($server2);
>> $telnet->waitfor('/login: $/i');
>> $telnet->print('hs767s');
>> $telnet->waitfor('/password: $/i');
>> $telnet->print('india512');
>
> I hope that's not your real password.
>
>> $telnet->waitfor('/\$ $/i');
>>
>> #From Telnet, SSH to Server 3.
>>
>> $scmd = "$ssh = Net::SSH::Perl->new($server3)";
>
> Umm... you seem to be confused here. This string will be sent to
> $server2 as a *shell* command, not a Perl statement. If you want you
> could run perl on $server2 and pass it statements to execute, but to be
> honest it's probably easier just to use ssh(1) on the remote machine.
>
> Ben
>
I am guessing server2 is a "jump" box that has access to his network AND
the remote (server3) network. And server1 does not have access to the
network server3 is on...
look at ssh tunneling.
From google search:
http://www.revsys.com/writings/quicktips/ssh-tunnel.html
http://www.gb.nrao.edu/pubcomputing/tunnel-howto.shtml
from these you should be able to construct things to do as you need...
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 2251
***************************************