[30359] in Perl-Users-Digest
Perl-Users Digest, Issue: 1602 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 2 09:09:52 2008
Date: Mon, 2 Jun 2008 06:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 2 Jun 2008 Volume: 11 Number: 1602
Today's topics:
another bad perl tute (was Re: Perl read file eat up my <uri@stemsystems.com>
iCal default calendar <justin.0805@purestblue.com>
Re: iCal default calendar <benkasminbullock@gmail.com>
new CPAN modules on Mon Jun 2 2008 (Randal Schwartz)
Re: OT: SI units (was sorting a hash / 2008-06-01) <danrumney@77617270mail.net>
Re: OT: SI units (was sorting a hash / 2008-06-01) <jurgenex@hotmail.com>
Re: OT: SI units (was sorting a hash / 2008-06-01) <abigail@abigail.be>
pattern match timed-out question <lovecreatesbeauty@gmail.com>
Re: Perl read file eat up my memory... <howachen@gmail.com>
Re: Python's doc problems: sort <szrRE@szromanMO.comVE>
Re: Speed comparison of regex versus index, lc, and / / <abigail@abigail.be>
Re: The Importance of Terminology's Quality <szrRE@szromanMO.comVE>
The select() (IO::Select) function has a limit? <mcanato@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 02 Jun 2008 04:17:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: another bad perl tute (was Re: Perl read file eat up my memory...)
Message-Id: <x763ssjws1.fsf_-_@mail.sysarch.com>
>>>>> "h" == howa <howachen@gmail.com> writes:
h> Oh..., I google for "perl read file line by line" and return "http://
h> www.cs.cf.ac.uk/Dave/PERL/node241.html", I overlooked the code in that
h> page are not reading line by line in fact!
that web page is purported to be a book (dunno if a dead tree version
was printed) but it is up there with the other crappy web tutorials out
there. i wish i had the resources to catalog and critique them. so many
to choose from.
this one is very idiosyncratic with short pages with weak examples and
even worse and wrong explanations.
from:
http://www.cs.cf.ac.uk/Dave/PERL/node23.html#SECTION00411000000000000000
You define scalar variables by assigning a value (number or
string) to it.
hmm. that seems to mean my $foo is not defining (really declaring) a scalar.
* It is a good idea to declare all variables together near the
top of the program.
that is actually backwards.
and nothing is mentioned about all the other scalar value types in this
page. in fact this page is more about the values than about the title
'scalar variables'. the author doesn't seem to know the difference
between the container and its contents.
from: http://www.cs.cf.ac.uk/Dave/PERL/node24.html
String Scalar Variables
that page title is so wrong.
from:
http://www.cs.cf.ac.uk/Dave/PERL/node27.html
Literal Arrays
Arrays can be defined literally in Perl code by simply enclosing
the array elements in parentheses and separating each array
element with a comma.
For example
(1, 2, 3)
("fred", "albert")
() # empty array (zero elements)
wow. i can't even begin to comment on that balderdash. i have never
heard of the term literal array (we call them lists). don't you love
technical authors who invent new terms instead of using the well known
and accepted ones?
from:
http://www.cs.cf.ac.uk/Dave/PERL/node20.html#SECTION00322100000000000000
Example: Back-Quoted Strings
It might be argued that back-quoted strings are not really a
data type. That's because Perl uses back-quoted strings to
execute system commands. When Perl sees a back-quoted string, it
passes the contents to Windows, UNIX, or whatever operating
system you are using.
hmm. the author doesn't seem to realize that backticks also are double
quoted strings and are literals in that sense. the fact that they shell
out is a secondary effect.
Let's see how to use the back-quoted string to display a
directory listing of all text files in the perl5 directory:
print `dir *.txt`;
wow, a useless example given readdir and glob!
from:
http://www.cs.cf.ac.uk/Dave/PERL/node60.html#SECTION00910000000000000000
$refFunction = \&function; &{$refFunction} is a function location.
hmm. that calls the function ref. no location is returned.
of course he calls the tr/// op a regular expression. this is almost
universal in bad web tutes.
from:
http://www.cs.cf.ac.uk/Dave/PERL/node87.html#SECTION001180000000000000000
The binding operators (=~ and !~) are used as search, modify,
and translation operations and work on the $_ variable by
default.
actually if you use a bind op you DON'T default to operating on $_ but
on the bound value. wow.
from:
http://www.cs.cf.ac.uk/Dave/PERL/node81.html#SECTION001140000000000000000
The =~ lets you match against a specified target (rather than an
environment variable $_. In CGI (see Later) and other
application we frequently need to match against input
name/values.
this is even wackier. $_ is an environment variable? what is he smoking?
and why does he have 2 pages covering =~?
from:
http://www.cs.cf.ac.uk/Dave/PERL/node79.html#SECTION001121000000000000000
The control characters \d (digit), \s (space), \w (word
character) can also be used. \D, \S, \W are the negations of
\d\s\w (More on This Soon)
control characters??
ok, i had my fun. this is definitely the work of a dedicated author who
has never had anyone else comment on his work. i say this to my
students, job candidates, hiring clients, etc.: become part of the perl
community as you will learn more, gain valuable feedback and actually be
able to contribute something useful. writing (code or docs) in isolation
is never going to turn out well.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 02 Jun 2008 12:07:19 -0000
From: Justin C <justin.0805@purestblue.com>
Subject: iCal default calendar
Message-Id: <224e.4843e277.583a1@zem>
I have three calendars in iCal, Work, Home, and Automated (for script
triggers). While I'm at work most entries I want to add are for work,
while I'm at home most entries are personal ones (the two are synched
using .Mac). How can I set iCal on my iMac, and on my MBP, to default to
the relevant calendar for each location? It always seems to choose the
wrong one!
Justin.
--
Justin C, by the sea.
------------------------------
Date: Mon, 2 Jun 2008 12:54:48 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: iCal default calendar
Message-Id: <g20qio$fip$2@ml.accsnet.ne.jp>
On Mon, 02 Jun 2008 12:07:19 +0000, Justin C wrote:
> I have three calendars in iCal, Work, Home, and Automated (for script
> triggers). While I'm at work most entries I want to add are for work,
> while I'm at home most entries are personal ones (the two are synched
> using .Mac). How can I set iCal on my iMac, and on my MBP, to default to
> the relevant calendar for each location?
I don't want to seem like an ignorant fool, but what's an iCal, an iMac, an
MBP, a .Mac, or a script trigger? I've never heard of any of those things.
> It always seems to choose the wrong one!
You also seem to have chosen the wrong forum to ask your question.
------------------------------
Date: Mon, 2 Jun 2008 04:42:19 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jun 2 2008
Message-Id: <K1tJqJ.1unA@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.
API-PleskExpand-1.01
http://search.cpan.org/~nrg/API-PleskExpand-1.01/
OOP interface to the Plesk Expand XML API (http://www.parallels.com/en/products/plesk/expand/).
----
Abstract-Meta-Class-0.08
http://search.cpan.org/~adrianwit/Abstract-Meta-Class-0.08/
Simple meta object protocol implementation.
----
Abstract-Meta-Class-0.09
http://search.cpan.org/~adrianwit/Abstract-Meta-Class-0.09/
Simple meta object protocol implementation.
----
Acme-PSON-0.05
http://search.cpan.org/~tomyhero/Acme-PSON-0.05/
PSON(PerlScript Object Notation) Module
----
Class-Inspector-1.23
http://search.cpan.org/~adamk/Class-Inspector-1.23/
Get information about a class and its structure
----
Class-Lego-0.004
http://search.cpan.org/~ferreira/Class-Lego-0.004/
Build your classes with basic building blocks
----
Coat-0.330
http://search.cpan.org/~sukria/Coat-0.330/
A light and self-dependent meta-class for Perl5
----
Coat-Persistent-0.100
http://search.cpan.org/~sukria/Coat-Persistent-0.100/
Simple Object-Relational mapping for Coat objects
----
DBD-Pg-2.8.0
http://search.cpan.org/~turnstep/DBD-Pg-2.8.0/
PostgreSQL database driver for the DBI module
----
DBIx-Class-0.08099_02
http://search.cpan.org/~ash/DBIx-Class-0.08099_02/
Extensible and flexible object <-> relational mapper.
----
Devel-CoverX-Covered-0.012
http://search.cpan.org/~johanl/Devel-CoverX-Covered-0.012/
Collect and report caller (test file) and covered (source file) statistics from the cover_db
----
Devel-Declare-0.001008
http://search.cpan.org/~mstrout/Devel-Declare-0.001008/
----
Devel-Declare-0.1.7
http://search.cpan.org/~mstrout/Devel-Declare-0.1.7/
----
Devel-PPPort-3.14
http://search.cpan.org/~mhx/Devel-PPPort-3.14/
Perl/Pollution/Portability
----
Devel-PerlySense-0.0157
http://search.cpan.org/~johanl/Devel-PerlySense-0.0157/
Perl IDE backend with Emacs frontend
----
Devel-REPL-Plugin-NAS-0.000101
http://search.cpan.org/~oliver/Devel-REPL-Plugin-NAS-0.000101/
Add Perl to your network devices' command line interfaces
----
Devel-REPL-Plugin-NAS-0.000201
http://search.cpan.org/~oliver/Devel-REPL-Plugin-NAS-0.000201/
Add Perl to your network devices' command line interfaces
----
Devel-REPL-Plugin-NAS-0.0501
http://search.cpan.org/~oliver/Devel-REPL-Plugin-NAS-0.0501/
Add Perl to your network devices' command line interfaces
----
Digest-CMAC-0.04
http://search.cpan.org/~nuffin/Digest-CMAC-0.04/
The One-key CBC MAC message authentication code.
----
File-HStore-0.10
http://search.cpan.org/~adulau/File-HStore-0.10/
Perl extension to store files on a filesystem using a very simple hash-based storage.
----
File-Remove-1.41
http://search.cpan.org/~adamk/File-Remove-1.41/
Remove files and directories
----
Gtk2-Ex-WidgetCursor-3
http://search.cpan.org/~kryde/Gtk2-Ex-WidgetCursor-3/
mouse pointer cursor management for widgets
----
HTML-Stream-1.59
http://search.cpan.org/~dstaal/HTML-Stream-1.59/
HTML output stream class, and some markup utilities
----
Image-BoxModel-0.12
http://search.cpan.org/~mbp/Image-BoxModel-0.12/
Module for defining boxes on an image and putting things on them
----
MIME-BodyMunger-0.002
http://search.cpan.org/~rjbs/MIME-BodyMunger-0.002/
rewrite the content of text parts, minding charset
----
Mango-0.01000_13
http://search.cpan.org/~claco/Mango-0.01000_13/
An ecommerce solution using Catalyst, Handel and DBIx::Class
----
MooseX-Plaggerize-0.03
http://search.cpan.org/~tokuhirom/MooseX-Plaggerize-0.03/
plagger like plugin feature for Moose
----
MooseX-Plaggerize-0.04
http://search.cpan.org/~tokuhirom/MooseX-Plaggerize-0.04/
plagger like plugin feature for Moose
----
Net-OAuth-0.07
http://search.cpan.org/~kgrennan/Net-OAuth-0.07/
OAuth protocol support
----
POE-Filter-SAXBuilder-0.03_01
http://search.cpan.org/~martijn/POE-Filter-SAXBuilder-0.03_01/
A POE Filter for parsing XML with XML::LibXML
----
Parse-CPAN-Authors-2.27
http://search.cpan.org/~lbrocard/Parse-CPAN-Authors-2.27/
Parse 01mailrc.txt.gz
----
Parse-MediaWikiDump-0.51
http://search.cpan.org/~triddle/Parse-MediaWikiDump-0.51/
Tools to process MediaWiki dump files
----
Persistence-Entity-0.03
http://search.cpan.org/~adrianwit/Persistence-Entity-0.03/
Persistence API for perl classes.
----
Persistence-Entity-0.04
http://search.cpan.org/~adrianwit/Persistence-Entity-0.04/
Persistence API for perl classes.
----
Proc-Exists-0.12
http://search.cpan.org/~brianski/Proc-Exists-0.12/
quickly check for process existence
----
RDF-Redland-DIG-0.02
http://search.cpan.org/~drrho/RDF-Redland-DIG-0.02/
DIG extension for Redland RDF (Reasoner)
----
SQL-Entity-0.04
http://search.cpan.org/~adrianwit/SQL-Entity-0.04/
Entity sql abstraction layer.
----
Scalar-Lazy-0.01
http://search.cpan.org/~dankogai/Scalar-Lazy-0.01/
Yet another lazy evaluation in Perl
----
Scalar-Lazy-0.02
http://search.cpan.org/~dankogai/Scalar-Lazy-0.02/
Yet another lazy evaluation in Perl
----
Scalar-Lazy-0.03
http://search.cpan.org/~dankogai/Scalar-Lazy-0.03/
Yet another lazy evaluation in Perl
----
Scalar-Vec-Util-0.03
http://search.cpan.org/~vpit/Scalar-Vec-Util-0.03/
Utility routines for vec strings.
----
Software-License-0.005
http://search.cpan.org/~rjbs/Software-License-0.005/
packages that provide templated software licenses
----
TaskForest-1.12
http://search.cpan.org/~enoor/TaskForest-1.12/
Simple, powerful task scheduler
----
Test-DBUnit-0.07
http://search.cpan.org/~adrianwit/Test-DBUnit-0.07/
Database test framework.
----
Text-Editor-Easy-0.3
http://search.cpan.org/~grommier/Text-Editor-Easy-0.3/
A perl module to edit perl code with syntax highlighting and more.
----
Text-Summary-MediaWiki-0.02
http://search.cpan.org/~dgl/Text-Summary-MediaWiki-0.02/
Produce a short summary from MediaWiki markup
----
TextMate-JumpTo-0.07
http://search.cpan.org/~andya/TextMate-JumpTo-0.07/
Tell TextMate to jump to a particular file, line
----
Thread-Queue-2.09
http://search.cpan.org/~jdhedden/Thread-Queue-2.09/
Thread-safe queues
----
Transform-Simple-0.01
http://search.cpan.org/~dtrischuk/Transform-Simple-0.01/
a simple data-driven class for doing data transformation.
----
URI-http-Dump-0.01
http://search.cpan.org/~ecarroll/URI-http-Dump-0.01/
A module to assist in the reverse engineering of URL parameters.
----
WWW-Search-Ask-1.007
http://search.cpan.org/~mthurn/WWW-Search-Ask-1.007/
class for searching www.search.com
----
mobirc-0.99_02
http://search.cpan.org/~tokuhirom/mobirc-0.99_02/
modern IRC to HTTP gateway
----
mobirc-0.99_03
http://search.cpan.org/~tokuhirom/mobirc-0.99_03/
modern IRC to HTTP gateway
----
stockmonkey-1.3
http://search.cpan.org/~jettero/stockmonkey-1.3/
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: Sun, 01 Jun 2008 21:44:02 -0400
From: Dan Rumney <danrumney@77617270mail.net>
Subject: Re: OT: SI units (was sorting a hash / 2008-06-01)
Message-Id: <4843506f$0$7078$4c368faf@roadrunner.com>
[snip]
>> Since the US uses Fahrenheit for its temperatures and these are all US
>> cities, then Fahrenheit does seem like an appropriate choice, don't you
>> think?
>
> Well, very much depends on your target audience. If you never ever will
> use that program/that data outside of the Fahrenheit enclave, then using
> Fahrenheit is quite acceptable.
>
> However if there is even the tiniest chance that this program/this data
> is ever to be used outside of the Fahrenheit island then you should
> consider international standards right from the beginning. Believe me,
> de-localizing code and making it global is a _MAJOR_ pain. It is much
> worse than writing globalized code right from the get-go. Been there,
> done that for many years.
I agree in principle that code that deals with human measurement units
should *at least* be aware of the fact that there are different
measurement systems. As a general rule, I would defer to your wider
experience (I infer from your name that you're European, so you're
probably a little more exposed to issues of internationalisation than US
developers)
However, in the particular case of temperature and weather, there really
are only two measurement systems: Fahrenheit and Celcius (or Centigrade,
if you prefer). Since a pragmatic script that is internationalized would
allow the user to choose their unit of choice for display, it's academic
which system is used inside the Perl script... this could be easily
hidden from the calling script by a wrapper function performing the
necessary conversions.
Heck, you could store the temperatures in Kelvin, the true SI unit for
temperature and convert to C or F as required by the calling function :o)
>
>> Also, since the script is clearly about the average temperature with
>> regards to the weather, the choice of units is hardly a *critical* one
>> and so widespread local convention would seem to be the sensible choice.
>
> 'Widespread' and 'local' is kind of a contradiction ;-))
*blush* good point. Perhaps 'Widely-accepted' and 'regional' would have
been better choices
------------------------------
Date: Mon, 02 Jun 2008 03:16:29 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: OT: SI units (was sorting a hash / 2008-06-01)
Message-Id: <reo644dksfomvj8ua2ig5q0fmro9mmj77q@4ax.com>
Dan Rumney <danrumney@77617270mail.net> wrote:
>I agree in principle that code that deals with human measurement units
>should *at least* be aware of the fact that there are different
>measurement systems. As a general rule, I would defer to your wider
>experience
Wow, I feel flattered.
> (I infer from your name that you're European, so you're
>probably a little more exposed to issues of internationalisation than US
>developers)
Indeed. And I have been teaching US developers for years that it is a
very bad idea to just append an 's' to a word if you want to create the
plural of that word. Among many other things.
>However, in the particular case of temperature and weather, there really
>are only two measurement systems: Fahrenheit and Celcius (or Centigrade,
Now that is one of my pet peeves! A centigrade by definition of the
prefix centi is one hundreds of a grade or degree. So 36 degrees
centigrade are 0.36 degrees, but in what system?
Even the combination 130 centigrade Fahrenheit makes total sense and
would be 1.3 degree Fahrenheit. Very likely not what the person using
centigrade had in mind.
>if you prefer). Since a pragmatic script that is internationalized would
>allow the user to choose their unit of choice for display, it's academic
>which system is used inside the Perl script... this could be easily
>hidden from the calling script by a wrapper function performing the
>necessary conversions.
>
>Heck, you could store the temperatures in Kelvin, the true SI unit for
>temperature and convert to C or F as required by the calling function :o)
Not a bad idea at all.
Except that all scientific use including any weather reporting station
even in the US(!) uses Celsius, see e.g. aviation weather reports and
forecasts. Therefore degree Celsius appears to be the most convenient
unit for interal storage where you would need the least number of
conversions.
jue
------------------------------
Date: 02 Jun 2008 10:57:28 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: OT: SI units (was sorting a hash / 2008-06-01)
Message-Id: <slrng47kgn.6ns.abigail@alexandra.abigail.be>
_
sheinrich@my-deja.com (sheinrich@my-deja.com) wrote on VCCCLXXXVI
September MCMXCIII in <URL:news:909e7d1f-f37a-4e85-96de-c35f800e6a60@a70g2000hsh.googlegroups.com>:
:: On May 30, 9:21 am, "dn.p...@gmail.com" <dn.p...@gmail.com> wrote:
::
:: ...
:: >
:: > my %hash = () ;
:: > $hash{Calif}{San Jose}{max_temp} = 84 ;
:: > $hash{Calif}{San Fran}{max_temp} = 94 ;
:: > $hash{Calif}{Cupertino}{max_temp} = 38 ;
:: > $hash{Calif}{Fremont}{max_temp} = 66 ;
:: > $hash{Texas}{Dallas}{max_temp} = 72 ;
:: > $hash{Texas}{Austin}{max_temp} = 96 ;
:: > $hash{Texas}{Fort Worth}{max_temp} = 62 ;
:: > $hash{Mass}{Boston}{max_temp} = 96 ;
:: > $hash{Mass}{Framingham}{max_temp} = 55 ;
:: > $hash{Mass}{Worcester}{max_temp} = 55 ;
:: >
:: Excuse me, but is it really absolutely unthinkable to share your
:: information with the meager 99% percent of the world that has adopted
:: SI units decades(!) ago?
The USA makes up for about 4.5% of the world population, so even if the
rest of the world would use Celsius, it would only be 95%. But how many
of those 95% actually care about the four hottest cities in the USA, as
compared to the 4.5% that uses Fahrenheit?
Besides, they are just numbers, and considering that the mapping between
Celsius and Fahrenheid is monotonic and continuous, it doesn't make no
difference at all for his question (how to get the four hottest cities)
whether the temparatures are in Celsius or Fahrenheit.
Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";
------------------------------
Date: Mon, 2 Jun 2008 04:21:37 -0700 (PDT)
From: "lovecreatesbea...@gmail.com" <lovecreatesbeauty@gmail.com>
Subject: pattern match timed-out question
Message-Id: <4bd0f81e-981c-4756-b3db-aad2a04c6e26@w8g2000prd.googlegroups.com>
Hi,
I have one machine (192.168.5.10 below) that provides a telnet account
``guest'' and doesn't need a password to this telnet account. Another
machine (192.168.4.30 below) requires password when I telnet to it
with its ``guest'' account. They both prompt on screen the same
"login: " when I manually telnet to them. With the following login
prompt, it fails on .5.10 but succeeds on .4.30.
my $lg_prom = '/login[: ]*$/i';
$cnn->waitfor($lg_prom);
Where am I wrong?
I have one more question. I think root user remotely telnet is
disabled defaultly but root ssh connection is enabled, is this
standard rule?
Thank you for your time.
(1) manual telnet
$ telnet "192.168.4.30"
Trying 192.168.4.30...
Connected to 192.168.4.30.
Escape character is '^]'.
Linux 2.6.16.33-DA ((none)) (ttyp0)
login: guest
Password:
[guest@(none) ~]$ exit
logout
Connection closed by foreign host.
$
$ telnet "192.168.5.10"
Trying 192.168.5.10...
Connected to 192.168.5.10.
Escape character is '^]'.
Linux 2.4.18-3-DA (BS3000e-0) (18:51 on Monday, 02 June 2008)
login: guest
[guest@BS3000e-0 test]$ exit
logout
Connection closed by foreign host.
$
(2) scripting telnet in my perl code
$ perl rcmd.pl "telnet" "pwd" "192.168.4.30" "guest" "welcome" "root"
/root
[root@(none) ~]
$
$ perl rcmd.pl "telnet" "ls" "192.168.5.10" "guest" "" "root"
pattern match timed-out at rcmd.pl line 50
$
(LINE 50 marked out below)
(3) my code does scripting telnet
################################################################################
# Filename : rcmd.pl
# Synopsis : rcmd.pl <prot> <cmd> <host> <user> [pwd] [pwd2]
# Author : lijh@uit.com.cn
# Date : May 30, 2008
################################################################################
#!/usr/bin/perl
use Net::Telnet();
use Net::SSH::Perl();
sub rcmd_usage;
sub rcmd;
exit rcmd(@ARGV);
################################################################################
# Function : rcmd <prot> <cmd> <host> <user> [pwd] [pwd2]
# Description : Execute command on remote host. root privilege may be
required
# on some commands. This script is intended to automatically
# telnet to remote host or ssh to remote host in which neither
# /etc/hosts.equiv nor ~/.rhosts files may be available.
# Arguments : prot - telnet or ssh protocol to connect to host,
# cmd - command is to run on host,
# host - ip or name of host,
# user - user account to log on host,
# pwd - user's password,
# pwd2 - an alternative password, eg roots password if in need.
# Return : return 0 on success, otherwise non-zero.
################################################################################
sub rcmd
{
my ($prot, $cmd, $host, $user, $pwd, $pwd2) = @_;
my ($narg, $npwd, $npwd2) = (scalar(@ARGV), length($pwd),
length($pwd2));
my $cnn, @aout, $sout;
my $lg_prom = '/login[: ]*$/i', $pwd_prom = '/password[: ]*$/i';
if ($narg < 4 || $narg > 6){
rcmd_usage;
exit 1;
}
# telnet with non-root, roots password required to execute other
command
# on remote host; or login directly with root on ssh connection.
if ($prot =~ /[Tt][Ee][Ll][Nn][Ee][Tt]/){
$cnn = new Net::Telnet();
$cnn->open($host);
$cnn->waitfor($lg_prom); ### LINE 50 ###
$cnn->print($user);
if ($npwd != 0){
$cnn->waitfor($pwd_prom);
$cnn->print($pwd);
}
$cnn->waitfor($cnn->prompt);
$cnn->print("su -");
$cnn->waitfor($pwd_prom);
$cnn->print($pwd2);
$cnn->waitfor($cnn->prompt);
@aout = $cnn->cmd($cmd);
} elsif ($prot =~ /[Ss][Ss][Hh]/){
$cnn = Net::SSH::Perl->new($host);
$cnn->login($user, $pwd);
@aout = $cnn->cmd($cmd);
} else {
rcmd_usage;
return 1;
}
print "@aout\n";
return 0;
}
################################################################################
# Function : rcmd_usage
# Description : print the usage of rcmd function
################################################################################
sub rcmd_usage
{
my $s = "Usage: rcmd.pl <prot> <cmd> <host> <user> [pwd] [pwd2]";
print "$s\n";
}
------------------------------
Date: Sun, 1 Jun 2008 19:19:18 -0700 (PDT)
From: howa <howachen@gmail.com>
Subject: Re: Perl read file eat up my memory...
Message-Id: <e7659c5e-28e9-437e-9ab1-9e9e893b4bcb@s33g2000pri.googlegroups.com>
Hi,
On 6=D4=C22=C8=D5, =C9=CF=CE=E73=95r27=B7=D6, J=A8=B9rgen Exner <jurge...@ho=
tmail.com> wrote:
> howa <howac...@gmail.com> wrote:
> >Now, I have a program to read the file line by line:
>
> > foreach $line (<IN_FILE>) {
>
> But you don't. You are creating a list of all the lines in the file,
> then looping through that list.
>
> You are probably looking for
> while (my $line=3D <IN_FILE>) {
>
> jue
Oh..., I google for "perl read file line by line" and return "http://
www.cs.cf.ac.uk/Dave/PERL/node241.html", I overlooked the code in that
page are not reading line by line in fact!
Thanks guys!
Howard
------------------------------
Date: Sun, 1 Jun 2008 22:24:42 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Python's doc problems: sort
Message-Id: <g2006q0q3@news4.newsguy.com>
szr wrote:
> Jürgen Exner wrote:
>> "Andrew Koenig" <ark@acm.org> wrote:
>>> <xahlee@gmail.com> wrote in message
>>
>> [Subject: Python's doc problems: sort]
>>>> I want to emphasize a point here, as i have done quite emphatically
>>>> in the past. The Python documentation, is the world's worst
>>>> technical
>>
>> And WTF does Python documentation have to do with Perl of Lisp?
>>
>> szr, do you still have any doubts about the nature of xahlee?
>
> I wasn't involved in this thread, but no, after that statement
> comparing Perl's and Python's docs, I no doubts.
* should have been, ", I have no doubts."
--
szr
------------------------------
Date: 02 Jun 2008 10:36:47 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Speed comparison of regex versus index, lc, and / /i
Message-Id: <slrng47j9v.6ns.abigail@alexandra.abigail.be>
_
Ben Morrow (ben@morrow.me.uk) wrote on VCCCLXXXVII September MCMXCIII in
<URL:news:5j68h5-eq3.ln1@osiris.mauzo.dyndns.org>:
:)
:) Quoth abigail@abigail.be:
:) > Ben Morrow (ben@morrow.me.uk) wrote on VCCCLXXXVII September MCMXCIII in
:) > <URL:news:mas6h5-nt11.ln1@osiris.mauzo.dyndns.org>:
:) > ""
:) > "" Note that m// will only use the precompiled form of the qr// if the
:) > "" $rx is the only thing in the match. Something like /^$rx/ or
:) > "" /$rx1|$rx2/ or even / $rx/x will cause the regex to be recompiled
:) > "" every time all over again.
:) >
:) > That hasn't been the case for over a decade or so:
:) >
:) > perl -Mre=debug -wE '$re = qr /foo/;
:) > for (qw [bar baz]) {/ $re/}' 2>&1| grep '^Compiling'
:) > Compiling REx "foo"
:) > Compiling REx " (?-xism:foo)"
:) >
:) > It only compiles twice, once for the qr //, and once for the m //.
:)
:) You know, I did actually test that :).
:)
:) ~% perl -Mre=debug -e'$qr=qr/a/; /$qr/' 2>&1 | grep Comp
:) Compiling REx `a'
:) ~% perl -Mre=debug -e'$qr=qr/a/; / $qr/x' 2>&1 | grep Comp
:) Compiling REx `a'
:) Compiling REx ` (?-xism:a)'
:)
:) If it's actually using the compiled form of the qr//, it doesn't need to
:) compile for the m// at all. The fact your example only compiles the m//
:) once is the 'if a variable hasn't changed, don't recompile'
:) optimization, which applies regardless of qr//:
:)
:) ~% perl -Mre=debug -e'$qr=qr/a/; / $qr/ for 1, 2' 2>&1 | grep Comp
:) Compiling REx `a'
:) Compiling REx ` (?-xism:a)'
:) ~% perl -Mre=debug -e'$qr=q/a/; / $qr/ for 1, 2' 2>&1 | grep Comp
:) Compiling REx ` a'
Well, yes, and I don't say it doesn't. But you said
"Something like /^$rx/ or /$rx1|$rx2/ or even / $rx/x will
cause the regex to be recompiled every time all over again.",
which isn't true. If $rx doesn't change, it will be compiled *once*
and not recompiled again.
Abigail
:)
:) > Out of obfuscated code, I would never use /o.
:)
:) Me either.
:)
:) Ben
:)
--
perl -swleprint -- -_='Just another Perl Hacker'
------------------------------
Date: Sun, 1 Jun 2008 22:45:25 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: The Importance of Terminology's Quality
Message-Id: <g201dm02c7@news4.newsguy.com>
Arne Vajhøj wrote:
> szr wrote:
>> Arne Vajhøj wrote:
>>> szr wrote:
>>>> Peter Duniho wrote:
>>>>> On Fri, 30 May 2008 22:40:03 -0700, szr <szrRE@szromanMO.comVE>
>>>>> wrote:
>>>>>> Arne Vajhøj wrote:
>>>>>>> Stephan Bour wrote:
>>>>>>>> Lew wrote:
>>>>>>>> } John Thingstad wrote:
>>>>>>>> } > Perl is solidly based in the UNIX world on awk, sed, } >
>>>>>>>> bash and C. I don't like the style, but many do.
>>>>>>>> }
>>>>>>>> } Please exclude the Java newsgroups from this discussion.
>>>>>>>>
>>>>>>>> Did it ever occur to you that you don't speak for entire news
>>>>>>>> groups?
>>>>>>> Did it occur to you that there are nothing about Java in the
>>>>>>> above ?
>>>>>> Looking at the original post, it doesn't appear to be about any
>>>>>> specific language.
>>>>> Indeed. That suggests it's probably off-topic in most, if not
>>>>> all, of the newsgroups to which it was posted, inasmuch as they
>>>>> exist for topics specific to a given programming language.
>>>> Perhaps - comp.programming might of been a better place, but not
>>>> all people who follow groups for specific languages follow a
>>>> general group like that - but let me ask you something. What is it
>>>> you really have against discussing topics with people of
>>>> neighboring groups? Keep in mind you don't have to read anything
>>>> you do not want to read. [1]
>>> I very much doubt that the original thread is relevant for the Java
>>> group.
>>>
>>> But the subthread Lew commente don was about Perl and Unix. That is
>>> clearly off topic.
>>
>> I agree with and understand what you are saying in general, but
>> still, isn't it possible that were are people in the java group (and
>> others) who might of been following the thread, only to discover
>> (probably not right away) that someone decided to remove the group
>> they were reading the thread from? I know I would not like that,
>> even if it wasn't on topic at the branch.
>>
>> Personally, I find it very annoying to have to switch news groups in
>> order to resume a thread and weed my way down the thread to where it
>> left off before it was cut off from the previous group.
>
> I am relative tolerant towards threads that are a bit off topic, if
> the S/N ratio overall is good.
Agreed.
[...]
If a thread, that is cross-posted, branches off on a tangent that has
nothing to do with one or more groups what so ever, then yes, it makes
sense to prune the 'newsgroup:' list / set follow ups, but in this case,
someone made one mention or so of 'Perl', which was being used as an
example, and someone (lew) moved to have the Java group removed.
There was little reason to cut off the thread, when people very well may
have been following it, over the utterance of one word, which was being
used as an example. The bulk of the thread had to do with general
programming, and suddenly writing the name of a language doesn't mean
it's way off on a tangent.
I hope this clears up some waters.
Regards.
--
szr
------------------------------
Date: Mon, 2 Jun 2008 02:24:53 -0700 (PDT)
From: peste <mcanato@gmail.com>
Subject: The select() (IO::Select) function has a limit?
Message-Id: <0a33d453-ada4-48c9-9748-072da3231b51@z72g2000hsb.googlegroups.com>
Hi list,
i'm writing a daemon in perl for exchanging data from a big quantity
of machines (over 100000) over the network and I use the select()
function in order to select the correct file handler (to read or
write).
All is fine when the number of clients is <100, but when arrives the
101th client the connection with this is dropped.
Is this a limit of the IO::Select?
Thanks,
M.Canato
------------------------------
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 1602
***************************************