[30054] in Perl-Users-Digest
Perl-Users Digest, Issue: 1297 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 22 03:09:42 2008
Date: Fri, 22 Feb 2008 00:09:07 -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 Fri, 22 Feb 2008 Volume: 11 Number: 1297
Today's topics:
compare array element <rose@russ.org>
Re: compare array element <see@sig.invalid>
Re: compare array element <noreply@gunnar.cc>
Re: compare array element <rose@russ.org>
Re: How to call a TCL script from within a perl scrip/p <jurgenex@hotmail.com>
Re: how to retrieve info <tadmc@seesig.invalid>
I don't understand the Net::Telnet error <cdalten@gmail.com>
Interactive apps with Perl sunilkjin@gmail.com
Re: Interactive apps with Perl <cartercc@gmail.com>
new CPAN modules on Fri Feb 22 2008 (Randal Schwartz)
Re: setting %ENV in a module <noone@nowhere.com>
Re: setting %ENV in a module <tadmc@seesig.invalid>
Re: Trying to properly use WWW::Mechanize dummy@phony.info
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Feb 2008 11:28:25 +0800
From: "Rose" <rose@russ.org>
Subject: compare array element
Message-Id: <fplfgs$v6m$1@ijustice.itsc.cuhk.edu.hk>
I find the following codes will give match for 'C' to '-', what's the
problem?
$preseq = "C-";
@preseq = splilt '', $preseq;
$curseq = "--";
@curseq = splilt '', $curseq;
$len = @curseq;
$len--;
if ($preseq[$len-1] == $curseq[$len-1]) {
print "P:$preseq[$len-1]\n";
print "C:$curseq[$len-1]\n";
}
------------------------------
Date: Thu, 21 Feb 2008 22:51:29 -0500
From: Bob Walton <see@sig.invalid>
Subject: Re: compare array element
Message-Id: <47be46cc$0$6164$4c368faf@roadrunner.com>
Rose wrote:
> I find the following codes will give match for 'C' to '-', what's the
> problem?
>
> $preseq = "C-";
> @preseq = splilt '', $preseq;
>
> $curseq = "--";
> @curseq = splilt '', $curseq;
>
> $len = @curseq;
> $len--;
>
> if ($preseq[$len-1] == $curseq[$len-1]) {
------------------------------^^
> print "P:$preseq[$len-1]\n";
> print "C:$curseq[$len-1]\n";
> }
One problem is you are using the numeric comparison operator "==" where
you should be using the string comparison operator "eq". The "=="
operator coerces both arguments to numbers, which means 0 for strings
that don't make sense as numbers.
HTH
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Fri, 22 Feb 2008 05:01:37 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: compare array element
Message-Id: <626vstF21m6vnU1@mid.individual.net>
Rose wrote:
> I find the following codes will give match for 'C' to '-', what's the
> problem?
>
> $preseq = "C-";
> @preseq = splilt '', $preseq;
>
> $curseq = "--";
> @curseq = splilt '', $curseq;
>
> $len = @curseq;
> $len--;
>
> if ($preseq[$len-1] == $curseq[$len-1]) {
> print "P:$preseq[$len-1]\n";
> print "C:$curseq[$len-1]\n";
> }
The problem is that you ask for help with debugging, while you haven't
first asked Perl for help by using strictures and warnings.
Add
use strict;
use warnings;
to the beginning of the script, and make the adjustments needed to get
rid of possible error and warning messages.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 22 Feb 2008 13:14:06 +0800
From: "Rose" <rose@russ.org>
Subject: Re: compare array element
Message-Id: <fplln1$26m$1@ijustice.itsc.cuhk.edu.hk>
Thanks to both Bob Walton's explanation and Gunnar Hjalmarsson's critics. I
feel very sorry for raising such stupid questions although I am very
hopeless to be ordered to learn several languages at the same time. I will
pay more attention to use strict and use warnings next time
------------------------------
Date: Thu, 21 Feb 2008 22:43:38 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to call a TCL script from within a perl scrip/program
Message-Id: <ffvrr310pia2k2f9d2lafnugmc82q2jr1m@4ax.com>
cyrusgreats@gmail.com wrote:
>I have a need to call a TCL script from within a perl scrip/program.
>What is the best way to do this. Has anyone done this before. Can
>anyone recommend a module for this.
perldoc -f system
perldoc -f qx
perldoc -f open (and check for mode | or |- or -|)
...
jue
------------------------------
Date: Thu, 21 Feb 2008 05:40:47 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: how to retrieve info
Message-Id: <slrnfrqopv.mq1.tadmc@tadmc30.sbcglobal.net>
Rose <rose@russ.org> wrote:
> i have hundreds of files to submit to
>
> http://propka.ki.ku.dk/~drogers/
>
> for analysis. the inputs are some 4-letter code, e.g. 1a00, 1brs, 2bti,
> 3bmn, ...
>
> How can I tell perl to submit the values
perldoc -q form
How do I automate an HTML form submission?
> and retrieve the results under a
> Linux platform?
perldoc -q HTML
How do I fetch an HTML file?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 21 Feb 2008 18:28:06 -0800 (PST)
From: grocery_stocker <cdalten@gmail.com>
Subject: I don't understand the Net::Telnet error
Message-Id: <83ecf2da-5f66-490c-b8a3-6d229ca9058b@s37g2000prg.googlegroups.com>
When I run the following on Linux Fedora Core 6
#!/usr/bin/perl
use warnings;
use strict;
use diagnostics;
{
my ($pty, $ssh, @lines);
my $host = "arbornet.org";
my $user = "cd";
my $password = "testme";
my $prompt = "/changeme:~> $/";
## Start ssh program.
$pty = &spawn("ssh", "-l", $user, $host); # spawn() defined below
## Create a Net::Telnet object to perform I/O on ssh's tty.
use Net::Telnet;
$ssh = new Net::Telnet (-fhopen => $pty,
-prompt => $prompt,
-telnetmode => 0,
-cmd_remove_mode => 1);
## Login to remote host.
#$ssh->open($host);
#$ssh->login($user, $pass);
$ssh->waitfor(-match => '/password: ?$/i', -errmode => "return")
or die "problem connecting to host: ", $ssh->lastline;
$ssh->print($password);
$ssh->waitfor(-match => $ssh->prompt, -errmode => "return")
or die "login failed: ", $ssh->lastline;
## Send command, get and print its output.
@lines = $ssh->cmd("who");
print @lines;
exit;
} # end main program
sub spawn {
my(@cmd) = @_;
my($pid, $pty, $tty, $tty_fd);
## Create a new pseudo terminal.
use IO::Pty ();
$pty = new IO::Pty or die $!;
## Execute the program in another process.
unless ($pid = fork) { # child process
die "problem spawning program: $!\n" unless defined $pid;
## Disassociate process from existing controlling terminal.
use POSIX ();
POSIX::setsid
or die "setsid failed: $!";
## Associate process with a new controlling
terminal.
$tty = $pty->slave;
$tty_fd = $tty->fileno;
close $pty;
## Make stdio use the new controlling terminal.
open STDIN, "<&$tty_fd" or die $!;
open STDOUT, ">&$tty_fd" or die $!;
open STDERR, ">&STDOUT" or die $!;
close $tty;
## Execute requested program.
exec @cmd
or die "problem executing $cmd[0]\n";
} # end child process
$pty;
} # end sub spawn
I get the following error message......
[cdalten@localhost ~]$ ./bot2.pl
Uncaught exception from user code:
problem connecting to host: Welcome to FreeBSD!
at ./bot2.pl line 24
[cdalten@localhost ~]$
The "Welcome to FreeBSD!" is part of the message on the remote server.
However, netstat shows that I'm conneced.
tcp 0 0 66.81.68.80:53169
69.39.89.95:22 ESTABLISHED
What is causing this error message and more to the point. How come the
"who" command doesn't get executed.
------------------------------
Date: Thu, 21 Feb 2008 19:56:30 -0800 (PST)
From: sunilkjin@gmail.com
Subject: Interactive apps with Perl
Message-Id: <1905eeb5-0987-4dff-9e69-a6952361bef0@p73g2000hsd.googlegroups.com>
Folks,
I am trying to build an interactive test application. I
would like to generate interactive commands to an existing
server(ftpd)
so commands like ftp 192.68.20.1
ace>login: xxxx
ace >password : yyyy
I should be able to mimic human intervention. Is this possible in
perl.
I do not want to add delay's . I prefer synching with the server. I
know this is possible in Expect. Is there any other scripting language
this is possible in say Tcl/tk/Perl/Python/Ruby? What language do you
suggest for such application? this feature in addition with strong
parsing capabilities is what I am looking for.
Thanks in advance
Sunil
------------------------------
Date: Thu, 21 Feb 2008 21:14:41 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Interactive apps with Perl
Message-Id: <daf8e6f8-f286-4650-9e53-beecc3882df7@v3g2000hsc.googlegroups.com>
On Feb 21, 10:56 pm, sunilk...@gmail.com wrote:
> I am trying to build an interactive test application.
Look for Expect.pm. Try CPAN.
http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod
CC
------------------------------
Date: Fri, 22 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Feb 22 2008
Message-Id: <JwML6H.xoL@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.
Alien-Selenium-0.09
http://search.cpan.org/~domq/Alien-Selenium-0.09/
installing and finding the Selenium Web test framework
----
Astro-SIMBAD-Client-0.012
http://search.cpan.org/~wyant/Astro-SIMBAD-Client-0.012/
Fetch astronomical data from SIMBAD 4.
----
CGI-Application-Plugin-View-HTML-Template-0.01
http://search.cpan.org/~mfuller/CGI-Application-Plugin-View-HTML-Template-0.01/
Automatically render HTML::Templates in CGI::Application
----
CORBA-Python-2.63
http://search.cpan.org/~perrad/CORBA-Python-2.63/
----
CatalystX-Example-YUIUploader-0.01
http://search.cpan.org/~rkrimen/CatalystX-Example-YUIUploader-0.01/
A YUI Uploader example for Catalyst
----
Common-CLI-0.02
http://search.cpan.org/~izut/Common-CLI-0.02/
Command line applications made easy.
----
DB2-Admin-2.8
http://search.cpan.org/~hbiersma/DB2-Admin-2.8/
Support for DB2 Administrative API from perl
----
DoubleBlind-0.01
http://search.cpan.org/~ilyaz/DoubleBlind-0.01/
Perl extension for data-obfuscation in double-blind experiments.
----
Fey-ORM-0.02
http://search.cpan.org/~drolsky/Fey-ORM-0.02/
A Fey-based ORM
----
Getopt-Lucid-0.17
http://search.cpan.org/~dagolden/Getopt-Lucid-0.17/
Clear, readable syntax for command line processing
----
HTML-FillInForm-Lite-0.06
http://search.cpan.org/~gfuji/HTML-FillInForm-Lite-0.06/
Fills in HTML forms with data
----
LaTeX-Pod-0.17
http://search.cpan.org/~schubiger/LaTeX-Pod-0.17/
Transform LaTeX source files to POD (Plain old documentation)
----
LaTeX-TOM-0.8_02
http://search.cpan.org/~schubiger/LaTeX-TOM-0.8_02/
A module for parsing, analyzing, and manipulating LaTeX documents.
----
Lingua-ZH-ZhuYin-0.01
http://search.cpan.org/~clsung/Lingua-ZH-ZhuYin-0.01/
The great new Lingua::ZH::ZhuYin!
----
Lyrics-Fetcher-AstraWeb-0.32
http://search.cpan.org/~bigpresh/Lyrics-Fetcher-AstraWeb-0.32/
Get song lyrics from lyrics.astraweb.com
----
Lyrics-Fetcher-LeosLyrics-0.02
http://search.cpan.org/~ealleniii/Lyrics-Fetcher-LeosLyrics-0.02/
Get song lyrics from leoslyrics.com
----
Mail-Builder-1.08
http://search.cpan.org/~maros/Mail-Builder-1.08/
Create e-mail messages with attachments, html text and inline images
----
MooseX-Async-0.04
http://search.cpan.org/~perigrin/MooseX-Async-0.04/
The Orphanange of Asynchronous Love Children
----
MooseX-POE-0.07
http://search.cpan.org/~perigrin/MooseX-POE-0.07/
The Illicit Love Child of Moose and POE
----
Music-Audioscrobbler-MPD-0.08
http://search.cpan.org/~ealleniii/Music-Audioscrobbler-MPD-0.08/
Module providing routines to submit songs to last.fm from MPD.
----
Music-Audioscrobbler-MPD-0.09
http://search.cpan.org/~ealleniii/Music-Audioscrobbler-MPD-0.09/
Module providing routines to submit songs to last.fm from MPD.
----
Music-Tag-Amazon-0.29
http://search.cpan.org/~ealleniii/Music-Tag-Amazon-0.29/
Plugin module for Music::Tag to get information from Amazon.com
----
Music-Tag-FLAC-0.31
http://search.cpan.org/~ealleniii/Music-Tag-FLAC-0.31/
Plugin module for Music::Tag to get information from flac headers.
----
Music-Tag-File-0.29
http://search.cpan.org/~ealleniii/Music-Tag-File-0.29/
Plugin module for Music::Tag to get information from filename and directory entries.
----
Net-Whois-Gateway-Client-0.01
http://search.cpan.org/~graykot/Net-Whois-Gateway-Client-0.01/
Interface to Net::Whois::Gateway::Server
----
Net-Whois-Gateway-Server-0.03
http://search.cpan.org/~graykot/Net-Whois-Gateway-Server-0.03/
whois gateway
----
Number-Nary-0.103
http://search.cpan.org/~rjbs/Number-Nary-0.103/
encode and decode numbers as n-ary strings
----
POE-Component-Client-Whois-Smart-0.06
http://search.cpan.org/~graykot/POE-Component-Client-Whois-Smart-0.06/
Provides very quick WHOIS queries with smart features.
----
POE-Component-Client-Whois-Smart-0.07
http://search.cpan.org/~graykot/POE-Component-Client-Whois-Smart-0.07/
Provides very quick WHOIS queries with smart features.
----
POE-Component-ResourcePool-0.01
http://search.cpan.org/~nuffin/POE-Component-ResourcePool-0.01/
Asynchronous generic resource management for POE based apps.
----
POE-Component-ResourcePool-Resource-TokenBucket-0.01
http://search.cpan.org/~nuffin/POE-Component-ResourcePool-Resource-TokenBucket-0.01/
Token bucket based resource (for throttling).
----
POE-Component-SmokeBox-Uploads-NNTP-0.02
http://search.cpan.org/~bingos/POE-Component-SmokeBox-Uploads-NNTP-0.02/
Obtain uploaded CPAN modules via NNTP.
----
POEIKC-0.00_06
http://search.cpan.org/~suzuki/POEIKC-0.00_06/
POE IKC daemon and client
----
Regexp-Whitespace-0.001_0
http://search.cpan.org/~ferreira/Regexp-Whitespace-0.001_0/
Whitespace insensitivity for regexes
----
Sub-Uplevel-0.19_02
http://search.cpan.org/~dagolden/Sub-Uplevel-0.19_02/
apparently run a function in a higher stack frame
----
Test-Run-0.0114
http://search.cpan.org/~shlomif/Test-Run-0.0114/
a new and improved test harness for TAP scripts.
----
Text-Markdown-1.0.14
http://search.cpan.org/~bobtfish/Text-Markdown-1.0.14/
Convert MultiMarkdown syntax to (X)HTML
----
Text-SimpleVaddrbook-0.01
http://search.cpan.org/~tomuschat/Text-SimpleVaddrbook-0.01/
a package to manage multiple vCard-files
----
Text-SimpleVcard-0.02
http://search.cpan.org/~tomuschat/Text-SimpleVcard-0.02/
a package to manage a single vCard
----
WWW-CPAN-0.009
http://search.cpan.org/~ferreira/WWW-CPAN-0.009/
CPAN as a web service
----
XML-DT-0.50
http://search.cpan.org/~ambs/XML-DT-0.50/
a package for down translation of XML files
----
autobox-2.20
http://search.cpan.org/~chocolate/autobox-2.20/
call methods on builtin types
----
autobox-Closure-Attributes-0.02
http://search.cpan.org/~sartak/autobox-Closure-Attributes-0.02/
closures are objects are closures
----
parrot-0.5.3
http://search.cpan.org/~pmic/parrot-0.5.3/
----
pfacter-1.10-1
http://search.cpan.org/~sschneid/pfacter-1.10-1/
Collect and display facts about the system
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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 21 Feb 2008 13:48:45 -0700
From: Dennis Roesler <noone@nowhere.com>
Subject: Re: setting %ENV in a module
Message-Id: <1NKdnRS0daYzfiDanZ2dnUVZ_s2tnZ2d@comcast.com>
pgodfrin wrote:
> ...snip...
>> Yes I'm aware of this - I think this is a scoping issue. So program A
>> loads the modules, and then calls it to set the environment values. I
>> only care for the variables set during that process, and any other
>> from the calling program. However, certain variables get set and
>> others are not set exactly right....
>>
I found the snippet of code inside this sub on the net somewhere and has
been tweaked for our use. I put it in a module that is library of
general purpose functions we use.
sub getEnv {
my $perlCommand = "perl -MData::Dumper -e 'print Dumper(\\\%ENV)';";
#my $sourceCommand = "/bin/ksh";
my $sourceCommand = "";
while(my $file = shift) {
carp("$file does not exist") && next unless(-e $file);
my $sourceLine = "$sourceCommand $file 1>&2";
my %tmp = %{eval('my ' . `. $sourceLine\n$perlCommand`)};
$ENV{$_} = $tmp{$_} for (keys %tmp);
}
}
Dennis
d underscore roesler at agilent dot com
------------------------------
Date: Thu, 21 Feb 2008 23:22:50 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: setting %ENV in a module
Message-Id: <slrnfrs1lg.sds.tadmc@tadmc30.sbcglobal.net>
pgodfrin <pgodfrin@gmail.com> wrote:
> ($l,$e,$v) = (/^(export\s+)(\w+)=(.+)/);
> $ENV{$e}="$v";
What values will those variables have if the string
in $_ does not happen to match your pattern?
if ( ($l,$e,$v) = (/^(export\s+)(\w+)=(.+)/) ) {
# do stuff with $l, $e and $v
}
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 22 Feb 2008 00:05:05 -0800
From: dummy@phony.info
Subject: Re: Trying to properly use WWW::Mechanize
Message-Id: <000tr396khuta5utkr2mgo70m4s6336scm@4ax.com>
On Fri, 01 Feb 2008 22:11:35 +0100, Joost Diepenmaat <joost@zeekat.nl>
wrote:
>Phil Powell <phillip.s.powell@gmail.com> writes:
>
>>> Strawberry perl *should* provide all the means you need to install cpan
>>> tarballs. Download the thing from CPAN yourself and then do the usual
>>> stuff.
>>>
>>> http://www.cpan.org/modules/INSTALL.html
>>
>> Upon doing so, I am prompted (via the instructions to run Makefile.PL)
>> to provide the directory where the SSL Headers are located, using as
>> default "C:\openssl". Where would I find the appropriate SSL Headers
>> in order to accomplish this?
>>
>See:
>http://search.cpan.org/src/DLAND/Crypt-SSLeay-0.57/README
>
>Specifically:
>
> "You must have OpenSSL or SSLeay installed before compiling this module.
> You can get the latest OpenSSL package from:
>
> http://www.openssl.org"
>
>
>As a general note, installing XS modules (especially ones that require
>additional libraries) on strawberry perl is possible but not exactly
>painless. strawberry provides only just about the minimum of
>infrastructure to support this.
>
>Activeperl's ppm packages are a *lot* friendlier to use, and you should
>reconsider your judgement if the only reason you're using it is that the
>activestate site is blocked. Get your manager to fix that.
>
>Joost.
I have been using Activeperl for some time, but just became aware of the
fact that their ppm's deliver v0.72 of WWW::Mechanize, and the CPAN
version is 1.34 ! I have a gazillion modules from Activeperl. I've
been getting wierd results and would like to upgrade. Can I have
Strawberry and Activeperl on the same (Windows) machine?
------------------------------
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 1297
***************************************