[28600] in Perl-Users-Digest
Perl-Users Digest, Issue: 9964 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 03:05:49 2006
Date: Tue, 14 Nov 2006 00:05:10 -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 Tue, 14 Nov 2006 Volume: 10 Number: 9964
Today's topics:
Re: Algorithm with HoA looping <hpbenton@scripps.edu>
Call graph analysis of perl source? <roy@panix.com>
Re: can i treat a subroutine call as an array? <tadmc@augustmail.com>
Re: how do i update one section of a page leaving rest? <bootiack@yahoo.com>
Re: how do i update one section of a page leaving rest? <bootiack@yahoo.com>
Re: how do i update one section of a page leaving rest? <bootiack@yahoo.com>
Re: how to show the number of the correct asnwer <jgibson@mail.arc.nasa.gov>
Re: how to show the number of the correct asnwer <someone@example.com>
Mail sending problem <markusin@yahoo.de>
new CPAN modules on Tue Nov 14 2006 (Randal Schwartz)
Re: PERL can't open file for logging (world writable di <premgrps@gmail.com>
Re: PERL can't open file for logging (world writable di <premgrps@gmail.com>
Re: perl exceptions and return value in finally block <benmorrow@tiscali.co.uk>
reverse chomp() <peretz.eyal@gmail.com>
Re: reverse chomp() koneruarjun@gmail.com
Re: reverse chomp() <john@castleamber.com>
Re: reverse chomp() <uri@stemsystems.com>
Re: reverse chomp() <kalyanrajsista@gmail.com>
Re: reverse chomp() <uri@stemsystems.com>
Re: reverse chomp() <dha@panix.com>
Re: simple regular expression <tadmc@augustmail.com>
Re: SSH Module: Accessing CLI box using SSH and not get <deepika.mediratta@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Nov 2006 18:17:06 -0800
From: "PB0711" <hpbenton@scripps.edu>
Subject: Re: Algorithm with HoA looping
Message-Id: <1163470626.150165.76410@i42g2000cwa.googlegroups.com>
So, I have found a very good module on cpan.
I'm dealing with amino acids so my data looks like
A => mass, formula, structure
T...
V....
S....
all 20 Amino acids
I have sorted out my looping problem with a nice extra counter in my
loops. I'll put the code up when I finish, or pseudo code.
thanks for the help thou,
------------------------------
Date: Mon, 13 Nov 2006 21:52:14 -0500
From: Roy Smith <roy@panix.com>
Subject: Call graph analysis of perl source?
Message-Id: <roy-EB8838.21521413112006@reader2.panix.com>
I have been given the "interesting" task of figuring out and documenting
16,000 lines perl. It's typical crud -- no comments, lots of global
variables, etc.
After poking at it for a while, it's obvious that what I need to do is
build a call graph. Are there any tools to help me do this?
------------------------------
Date: Mon, 13 Nov 2006 19:41:31 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: can i treat a subroutine call as an array?
Message-Id: <slrneli7mb.as1.tadmc@tadmc30.august.net>
Scott Bryce <sbryce@scottbryce.com> wrote:
> doolittle wrote:
>> Sorry to be a pest but why does the +(..) work?
>> just point me to the relevant docs, (i couldn't find anything under
>> additive operators)
>
> Look under print.
>
> http://perldoc.perl.org/functions/print.html
>
> The + is one way
A particularly poor way, when compared to the alternative way...
> to get around the "If it looks like a function, it is a
> function" rule.
The best way is to actually use parenthesis around the function's
argument list, even if you don't normally choose to put parens
around a function's arg list.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Nov 2006 23:12:20 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Re: how do i update one section of a page leaving rest?
Message-Id: <1163488340.741228.86550@h54g2000cwb.googlegroups.com>
On Nov 9, 12:03 am, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "g" == gavino <booti...@yahoo.com> writes: g> Uri Guttman wrote:
> >> >>>>> "g" == gavino <booti...@yahoo.com> writes:
> >>
> g> Michele Dondi wrote:
> >> >>
> >> >> Oh, you should have specified these details in the first place. Then
> >> >> it would have been easier to help you. So here's another try: open the
> >> >> sources for that web app in your favourite editor and write some code
> >> >> that will delete the section you don't like, and update it with the
> >> >> new content.
> >>
> g> You realise you come off as an idiot when you talk like this?
> >>
> >> nah, he was just treating you like the idiot you are. big difference.
> >>
> g> vote republican.
> >>
> >> more proof of your idiocy.
> >>
> >> uri
> >>
> >> --
> g> you are useless
>
> nah, just useless to you. and you don't count. i voted yesterday and
> that turned out to be very useful to our country.
>
> too bad to be you. have fun if you can. learn python. go bother them.
Don't bother me with your eurotrash blather.
If you don't know be silent. Less people will know you are stupid.
------------------------------
Date: 13 Nov 2006 23:13:54 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Re: how do i update one section of a page leaving rest?
Message-Id: <1163488434.472939.258450@i42g2000cwa.googlegroups.com>
On Nov 4, 3:58 am, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> gavino wrote:
> > vote republican.Hmmmmmm, last time I checked my country was a republic =
already, no need to
> vote against a Monarchy.
> Of course it might be different for you if you are a victim of King George
> in which case you should indeed vote in favour of restoring the republic.
>
> jue
George Bush: fixed clinton inflation, ficed 9-11, freed two countries,
vote republican. Europe can copy the USA but has a long way to go
until its living standard or schools catch up to usa.
------------------------------
Date: 13 Nov 2006 23:31:09 -0800
From: "gavino" <bootiack@yahoo.com>
Subject: Re: how do i update one section of a page leaving rest?
Message-Id: <1163489469.442943.237100@h48g2000cwc.googlegroups.com>
On Nov 2, 2:11 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 1 Nov 2006 22:44:23 -0800, "gavino" <booti...@yahoo.com> wrote:
>
>
>
> >> > How Do i updae one section of a page leaving the rest?
>
> >> You could open that page in your favourite editor, delete the section you
> >> don't like, and type in the new content.
> [snip]
> >thanks dude
> >The idea is to make cool web apps that are fast
> >A statik site wouldn't do well.Oh, you should have specified these details in the first place. Then
> it would have been easier to help you. So here's another try: open the
> sources for that web app in your favourite editor and write some code
> that will delete the section you don't like, and update it with the
> new content.
>
> >Remember to vote republican.I will remember. I won't do it. I couldn't anyway. So, it doesn't make
> a difference.
>
> Michele
oh what little country are you from?
------------------------------
Date: Mon, 13 Nov 2006 16:54:09 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: how to show the number of the correct asnwer
Message-Id: <131120061654093105%jgibson@mail.arc.nasa.gov>
In article <1163455516.993324.52100@i42g2000cwa.googlegroups.com>,
angel <angel_dsgs@yahoo.com> wrote:
> hello i am a perl beginner and i need help. i dont know and have no
> idea on how to make a program for this,
>
> the program should ask a user 5 questions. it should read the answers
> and shows the number of answers that were right.
>
[example input, output, and code snipped]
>
> my problem is i dont know on how it will read the answers and shows the
> number of answers that were right. i would really appreciate any help.
> thanks!
>
Perl variables can hold numbers and you can use them in arithmetic
expressions:
my $n_correct = 0;
...
$n_correct = $n_correct + 1;
which may be written less verbosely as:
$n_correct += 1;
or
$n_correct++;
Then:
print "The number of correct answers is: $n_correct\n";
------------------------------
Date: Tue, 14 Nov 2006 05:08:08 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: how to show the number of the correct asnwer
Message-Id: <Yac6h.4519$_Z2.3384@edtnps89>
angel wrote:
> hello i am a perl beginner and i need help. i dont know and have no
> idea on how to make a program for this,
>
> the program should ask a user 5 questions. it should read the answers
> and shows the number of answers that were right.
>
> example:
>
> Please enter £ two times: ££
> Correct!
>
> Please enter $ four times: ***
> Wrong!
>
> *****
>
> You got 4 correct answers.
>
> I have already written a program for the 5 questions:
>
> e.g.
>
> print ("Please enter £ two times: ");
> $pound = <STDIN>;
> $correct = "Correct!";
>
> if ($pound !~m/££/)
> {
> print("Wrong!\n");
> }
> else
> {
> print("$correct\n");
> }
>
> print("Please enter \$ four times: ");
> $dollar = <STDIN>;
>
> if($dollar !~m/^(\${4})$/)
> (
> print("Wrong!\n");
> }
> else
> {
> print("$correct\n");
> }
>
> my problem is i dont know on how it will read the answers and shows the
> number of answers that were right. i would really appreciate any help.
my @numbers = qw( zero one two three four five six seven eight nine ten eleven
twelve );
my @questions = ( [ qw/ £ 2 / ], [ qw/ $ 4 / ] );
my $correct = 0;
for my $question ( @questions ) {
print "Please enter $question->[0] $numbers[$question->[1]] times: ";
chomp( my $answer = <STDIN> );
print $answer eq ( $question->[0] x $question->[1] ) ? do { ++$correct;
"Correct!\n" } : "Wrong!\n";
}
print "You got $correct correct answer", $correct == 1 ? '' : 's', ".\n";
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Tue, 14 Nov 2006 08:23:01 +0000
From: Markusin <markusin@yahoo.de>
Subject: Mail sending problem
Message-Id: <45596e6d$0$7638$4fafbaef@reader1.news.tin.it>
Hi
I am trying to send a mail with perl, using as MTA ms exchange. On that
server I need to authenticate. I wrote a small programm with following code:
######################### Begin #######################################
#!/usr/bin/perl -w
use Mail::Mailer;
use MIME::Base64;
use Authen::SASL;
my $from = "markus\@empfaenger.net";
my $to = "markus\@sender.net";
my $subject = "markus perl probe";
my $text = "kleine perl probe";
my $args;
my $type = "smtp";
my $server = "exchange.server";
my $smtpuser = "Markus";
my $smtppasswd = "password";
push @args, Server => $server;
push @args, Auth => [$smtpuser, $smtppasswd];
my $mailer = Mail::Mailer->new($type, @args) or die "Kann kein neues
Mail::Mailer-Objekt erzeugen: $!\n";
$mailer->open({From => $from, To => $to, Subject => $subject}) or die
"Kann kein neues Mail::Mailer-Objekt oeffnen: $!\n";
print $mailer $text;
$mailer->close;
######################### End #######################################
On executing that script I receive following error message:
vajolet ~ # /home/markusin/scripts/mymailsender.pl
Invalid argument at /usr/lib/perl5/vendor_perl/5.8.8/Mail/Mailer.pm line
269.
Looking on that line in Mailer.pm :
268 # Fork and start a mailer
269 (defined($exe) && open($self,"|-"))
270 || $self->exec($exe, $args, \@to)
271 || die $!;
I don't know what I am doing wrong and need your help. Do I need to pass
a parameter, which in that script is required?
Any idea what that could be?
Thanks for any help
Markus
------------------------------
Date: Tue, 14 Nov 2006 05:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Nov 14 2006
Message-Id: <J8pH6D.3pn@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.
ACH-Builder-0.01
http://search.cpan.org/~tkeefer/ACH-Builder-0.01/
Tools for Building ACH (Automated Clearing House) Files
----
AI-PSO-0.81
http://search.cpan.org/~kylesch/AI-PSO-0.81/
Perl module for running the Particle Swarm Optimization algorithm
----
AI-PSO-0.82
http://search.cpan.org/~kylesch/AI-PSO-0.82/
Perl module for running the Particle Swarm Optimization algorithm
----
Acme-ProgressBar-1.121
http://search.cpan.org/~rjbs/Acme-ProgressBar-1.121/
a simple progress bar for the patient
----
Algorithm-RabinKarp-0.40
http://search.cpan.org/~nnunley/Algorithm-RabinKarp-0.40/
Rabin-Karp streaming hash
----
AuthCAS-1.1
http://search.cpan.org/~osalaun/AuthCAS-1.1/
Client library for CAS 2.0 authentication server
----
Boost-Graph-1.3
http://search.cpan.org/~dburdick/Boost-Graph-1.3/
Perl interface to the Boost-Graph C++ libraries.
----
CPAN-1.88_62
http://search.cpan.org/~andk/CPAN-1.88_62/
query, download and build perl modules from CPAN sites
----
CPAN-Mini-0.551
http://search.cpan.org/~rjbs/CPAN-Mini-0.551/
create a minimal mirror of CPAN
----
Catalyst-Plugin-I18N-DBIC-0.03
http://search.cpan.org/~icd/Catalyst-Plugin-I18N-DBIC-0.03/
Internationalization for Catalyst, data loaded from database
----
Class-Accessor-Class-0.501
http://search.cpan.org/~rjbs/Class-Accessor-Class-0.501/
simple class variable accessors
----
Color-Calc-1.02
http://search.cpan.org/~cfaerber/Color-Calc-1.02/
Simple calculations with RGB colors.
----
Crypt-OpenSSL-RSA-0.24
http://search.cpan.org/~iroberts/Crypt-OpenSSL-RSA-0.24/
RSA encoding and decoding, using the openSSL libraries
----
Danga-Socket-1.54
http://search.cpan.org/~bradfitz/Danga-Socket-1.54/
Event loop and event-driven async socket base class
----
Data-GUID-0.042
http://search.cpan.org/~rjbs/Data-GUID-0.042/
globally unique identifiers
----
Email-Delete-1.021
http://search.cpan.org/~rjbs/Email-Delete-1.021/
Delete Messages from Folders
----
Games-Bettor-1.00
http://search.cpan.org/~denkinger/Games-Bettor-1.00/
A class representing a bettor
----
HTTP-Daemon-App-v0.0.3
http://search.cpan.org/~dmuey/HTTP-Daemon-App-v0.0.3/
Create 2 or 3 line, fully functional (SSL) HTTP server(s)
----
Jifty-DBI-0.26
http://search.cpan.org/~jesse/Jifty-DBI-0.26/
An object-relational persistence framework
----
Linux-KernelSort-0.01
http://search.cpan.org/~ogasawara/Linux-KernelSort-0.01/
Perl extension for sorting and comparing Linux kernel versions. The expected kernel version naming convention is the same naming convetion demonstrated by http://www.kernel.org. NOTE: Currently, only
----
Math-TotalBuilder-1.101
http://search.cpan.org/~rjbs/Math-TotalBuilder-1.101/
build a whole total out of valued pieces
----
Net-GPSD-Server-Fake-0.01
http://search.cpan.org/~mrdvt/Net-GPSD-Server-Fake-0.01/
Provides a perl interface to the gpsd daemon.
----
Object-InsideOut-2.21
http://search.cpan.org/~jdhedden/Object-InsideOut-2.21/
Comprehensive inside-out object support module
----
POE-API-Peek-1.0802
http://search.cpan.org/~sungo/POE-API-Peek-1.0802/
Peek into the internals of a running POE environment
----
Parse-GutenbergRoget-0.021
http://search.cpan.org/~rjbs/Parse-GutenbergRoget-0.021/
parse Project Gutenberg's Roget's Thesaurus
----
Parse-IRCLog-1.101
http://search.cpan.org/~rjbs/Parse-IRCLog-1.101/
parse internet relay chat logs
----
Perlbal-1.52
http://search.cpan.org/~bradfitz/Perlbal-1.52/
Reverse-proxy load balancer and webserver
----
Rose-Object-0.821
http://search.cpan.org/~jsiracusa/Rose-Object-0.821/
A simple object base class.
----
SNMP-BridgeQuery-0.6
http://search.cpan.org/~jshearer/SNMP-BridgeQuery-0.6/
Perl extension for retrieving bridge tables.
----
SOAP-Data-ComplexType-0.042
http://search.cpan.org/~rybskej/SOAP-Data-ComplexType-0.042/
An abstract class for creating and handling complex SOAP::Data objects
----
SOAP-Data-ComplexType-0.043
http://search.cpan.org/~rybskej/SOAP-Data-ComplexType-0.043/
An abstract class for creating and handling complex SOAP::Data objects
----
SOAP-Data-ComplexType-0.044
http://search.cpan.org/~rybskej/SOAP-Data-ComplexType-0.044/
An abstract class for creating and handling complex SOAP::Data objects
----
Shell-EnvImporter-1.04
http://search.cpan.org/~dfaraldo/Shell-EnvImporter-1.04/
Perl extension for importing environment variable changes from external commands or shell scripts
----
String-Truncate-0.101
http://search.cpan.org/~rjbs/String-Truncate-0.101/
a module for when strings are too long to be displayed in...
----
Sub-Install-0.924
http://search.cpan.org/~rjbs/Sub-Install-0.924/
install subroutines into packages easily
----
Sub-MicroSig-0.031
http://search.cpan.org/~rjbs/Sub-MicroSig-0.031/
microsigs for microvalidation of sub arguments
----
Sub-Pipeline-0.010
http://search.cpan.org/~rjbs/Sub-Pipeline-0.010/
subs composed of sequential pieces
----
Tcl-0.91
http://search.cpan.org/~vkon/Tcl-0.91/
Tcl extension module for Perl
----
Text-DHCPparse-0.08
http://search.cpan.org/~jshearer/Text-DHCPparse-0.08/
Perl extension for parsing dhcpd lease files
----
Time-Piece-MSSQL-0.020
http://search.cpan.org/~rjbs/Time-Piece-MSSQL-0.020/
MSSQL-specific methods for Time::Piece
----
Tree-File-0.110
http://search.cpan.org/~rjbs/Tree-File-0.110/
store a data structure in a file tree
----
Unix-PID-v0.0.10
http://search.cpan.org/~dmuey/Unix-PID-v0.0.10/
Perl extension for getting PID info.
----
WWW-Scraper-ISBN-LibUniIt_Driver-0.1
http://search.cpan.org/~lucha/WWW-Scraper-ISBN-LibUniIt_Driver-0.1/
----
WWW-Translate-interNOSTRUM-0.03
http://search.cpan.org/~enell/WWW-Translate-interNOSTRUM-0.03/
Catalan < > Spanish machine translation
----
WWW-Translate-interNOSTRUM-0.04
http://search.cpan.org/~enell/WWW-Translate-interNOSTRUM-0.04/
Catalan < > Spanish machine translation
----
Wx-0.62
http://search.cpan.org/~mbarbon/Wx-0.62/
interface to the wxWidgets cross-platform GUI toolkit
----
Yahoo-Marketing-0.06
http://search.cpan.org/~jlavallee/Yahoo-Marketing-0.06/
an interface for Yahoo! Search Marketing's Web Services.
----
webrobot-0.81
http://search.cpan.org/~strcek/webrobot-0.81/
run a testplan
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: 13 Nov 2006 17:40:19 -0800
From: "PGPS" <premgrps@gmail.com>
Subject: Re: PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache)
Message-Id: <1163468419.315207.178020@b28g2000cwb.googlegroups.com>
Thank you all. I have been using relative path for my log files. When I
used the absolute path, it worked. The confusion started with my
changing all other paths to relative paths (images, .css etc.) and it
worked fine, except for the log files.
Thanks.
Joe Smith wrote:
> PGPS wrote:
>
> > open(LOGFILE, ">>/logs.html");
> >
> > DIRECTORY STRUCTURE
> > [htdocs]
> > logs.html
> > [cgi-bin]
> > [program1]
> > prog1.cgi
>
> That open() statement is definitely wrong.
>
> my $file = "$ENV{DOCUMENT_ROOT}/logs.html"; # Use full path name
> open(LOGFILE, ">>$file") or die "Cannot append to $file: $!\n";
>
> To access anything in htdocs, you need to either use a hardcoded
> absolute pathname (such as "/var/www/htdocs/logs.html") or use
> an ENV variable (such as what I've shown above).
>
> Remember, when the web server receives a request for "/logs.html"
> (such as from <a href="/logs.html">Log files</a>), it converts that
> string to a file name by using ServerRoot and/or DocumentRoot.
> Your CGI program needs to do the same thing; it cannot simply
> use the string "/logs.html" as it and expect it to work.
>
> -Joe
------------------------------
Date: 13 Nov 2006 17:40:46 -0800
From: "PGPS" <premgrps@gmail.com>
Subject: Re: PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache)
Message-Id: <1163468446.862824.105940@m73g2000cwd.googlegroups.com>
X-No-Archive: YES
Thank you all. I have been using relative path for my log files. When I
used the absolute path, it worked. The confusion started with my
changing all other paths to relative paths (images, .css etc.) and it
worked fine, except for the log files.
Thanks.
Joe Smith wrote:
> PGPS wrote:
>
> > open(LOGFILE, ">>/logs.html");
> >
> > DIRECTORY STRUCTURE
> > [htdocs]
> > logs.html
> > [cgi-bin]
> > [program1]
> > prog1.cgi
>
> That open() statement is definitely wrong.
>
> my $file = "$ENV{DOCUMENT_ROOT}/logs.html"; # Use full path name
> open(LOGFILE, ">>$file") or die "Cannot append to $file: $!\n";
>
> To access anything in htdocs, you need to either use a hardcoded
> absolute pathname (such as "/var/www/htdocs/logs.html") or use
> an ENV variable (such as what I've shown above).
>
> Remember, when the web server receives a request for "/logs.html"
> (such as from <a href="/logs.html">Log files</a>), it converts that
> string to a file name by using ServerRoot and/or DocumentRoot.
> Your CGI program needs to do the same thing; it cannot simply
> use the string "/logs.html" as it and expect it to work.
>
> -Joe
------------------------------
Date: Mon, 13 Nov 2006 23:57:52 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: perl exceptions and return value in finally block
Message-Id: <0ddn24-h4b.ln1@osiris.mauzo.dyndns.org>
Quoth rusland@scn.ru:
>
> > You can't "return" from a try.
> >
> > my $ret;
> > try {
> > if( condition ) { $ret = 'abc' }
> > elsif( condition2 ) { $ret='lmnop'; }
>
> Yes, I can use return at try, for example:
> #!/usr/bin/perl
>
> use strict;
> use Error qw(:try);
>
> sub apple {
> try {
> return 'fruit' if $_[0] eq 'apple';
> return 'possibly a fruit';
> }
> finally {
> print 'finally at apple(): ';
> };
> }
>
> print apple('apple'), "\n";
> print apple('berry'), "\n";
>
> exit;
>
>
> But problem is that I do not know what is return value in the finally
> block... :(
Don't do that then.
sub apple {
my $rv;
try {{
$rv = 'fruit', last if $_[0] eq 'apple';
$rv = 'possibly a fruit';
}}
finally {
print 'finally at apple(): $rv';
}
}
Note the {{ }} on the try: one set delimits the try block, the second
set creates a bare block so that last works.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
benmorrow@tiscali.co.uk
------------------------------
Date: 13 Nov 2006 20:12:28 -0800
From: "EZP" <peretz.eyal@gmail.com>
Subject: reverse chomp()
Message-Id: <1163477548.487551.327230@h48g2000cwc.googlegroups.com>
Hi all,
when i have a value like "max ", the chomp command will cut off
the spaces to "max".
How can i make " max" into "max"? (i need to cut the spaces from
the begining of the word.
thanks,
EZP
------------------------------
Date: 13 Nov 2006 20:15:19 -0800
From: koneruarjun@gmail.com
Subject: Re: reverse chomp()
Message-Id: <1163477719.635383.196430@e3g2000cwe.googlegroups.com>
s/^\s+//g
-Arjun
EZP wrote:
> Hi all,
> when i have a value like "max ", the chomp command will cut off
> the spaces to "max".
>
> How can i make " max" into "max"? (i need to cut the spaces from
> the begining of the word.
>
> thanks,
> EZP
------------------------------
Date: 14 Nov 2006 04:20:02 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: reverse chomp()
Message-Id: <Xns987AE3313C068castleamber@130.133.1.4>
"EZP" <peretz.eyal@gmail.com> wrote:
> Hi all,
> when i have a value like "max ", the chomp command will cut off
> the spaces to "max".
You're asking your question in the wrong group, since Perl's chomp command
does something entirely different.
perldoc -f chomp
> How can i make " max" into "max"? (i need to cut the spaces from
> the begining of the word.
perldoc perlrequick
Search and replace, if you want to search for leading space, and want to
replace it with nothing.
Other option is to match the first non white space looking from the start,
up until the end of the line.
Another option, if the leading space is always the same amount, you're
interested in the substring of the line that starts at position x.
perldoc -f substr
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Mon, 13 Nov 2006 23:23:08 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: reverse chomp()
Message-Id: <x7fycmodw3.fsf@mail.sysarch.com>
>>>>> "E" == EZP <peretz.eyal@gmail.com> writes:
E> Hi all,
E> when i have a value like "max ", the chomp command will cut off
E> the spaces to "max".
where did you get that idea? chomp removes a trailine line ending (or
what is in $/), not spaces.
E> How can i make " max" into "max"? (i need to cut the spaces from
E> the begining of the word.
someone else answered that. but you should read perldoc -f chomp and
learn what it really does.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 13 Nov 2006 21:45:10 -0800
From: "alwaysonnet" <kalyanrajsista@gmail.com>
Subject: Re: reverse chomp()
Message-Id: <1163483110.159499.32820@m7g2000cwm.googlegroups.com>
Question can be best quoted as " Stripping leading and trailing white
spaces "
HTH,
Raj
------------------------------
Date: Tue, 14 Nov 2006 01:03:37 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: reverse chomp()
Message-Id: <x73b8mo98m.fsf@mail.sysarch.com>
>>>>> "a" == alwaysonnet <kalyanrajsista@gmail.com> writes:
a> Question can be best quoted as " Stripping leading and trailing white
a> spaces "
i think i can figure that out.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 14 Nov 2006 07:16:24 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: reverse chomp()
Message-Id: <slrnelira8.pdq.dha@panix2.panix.com>
On 2006-11-14, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "E" == EZP <peretz.eyal@gmail.com> writes:
>
> E> Hi all,
> E> when i have a value like "max ", the chomp command will cut off
> E> the spaces to "max".
>
> where did you get that idea? chomp removes a trailine line ending (or
> what is in $/), not spaces.
Well, it would do what the OP suggests if $/ were to contain the right
number of spaces... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Beware of bugs in the above code; I have only proved it correct, not
tried it.
- Donald Knuth
------------------------------
Date: Mon, 13 Nov 2006 19:36:50 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: simple regular expression
Message-Id: <slrneli7di.as1.tadmc@tadmc30.august.net>
Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 11 Nov 2006, hjp-usenet2@hjp.at wrote:
> On 2006-11-10 18:05, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On 8 Nov 2006, asandstrom@accesswave.ca wrote:
>>>> There's a time and a place for regular expressions. But the string
>>>> functions exist for a reason and sometimes they're better.
>> Note that he wrote "better", not "faster". "Better" in code is usually a
>> mixture of several aspects and readability and maintainability are often
>> considered more important than performance.
>
> I think speed is the only aspect of code that everyone can agree on.
Not if they happen to have different data...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Nov 2006 20:48:24 -0800
From: "Deepika" <deepika.mediratta@gmail.com>
Subject: Re: SSH Module: Accessing CLI box using SSH and not getting the return output??
Message-Id: <1163479704.183071.40320@b28g2000cwb.googlegroups.com>
Hi ,
Thanks a lot for responding back. My code is really straightforward (as
easy as it can get):
use Net::SSH::Perl;
my $test = "xx.xx.xx.xx";
%params = ("debug",true);
my $sshtest = Net::SSH::Perl->new($test,%params);
my ($stdout, $stderr, $exit) = $sshtest->login("username","password");
print "\n value of stdout = $stdout \n";
print "\n value of stderr = $stderr \n";
print "\n value of exitt = $exit \n";
($stdout, $stderr, $exit) = $sshtest->cmd("?");
print "\n value of stdout = $stdout \n";
print "value of stderr = $stderr \n";
print "value of exitt = $exit \n";
Also running an ssh from the command line works. When I do an:
ssh user@ipaddress I actually enter the CLI session for the RNC(device
I am trying to access,like entering a Cisco switch) and can now enter
any commands.
If I run my script to enter the same commands, I don't get a reply
back.On the CLI manager I can't do an "ls" but I have tried various
commands and none of them come back with any output.
But as I mentioned if I use the same script above to access any other
linux box and do an ls command I actually see the output back.
J. Gleixner wrote:
> Deepika wrote:
> > Hi Everyone,
> >
> > I am trying to write a perl code to access and run few commands on a
> > Secure CLI-Box using SSH module in Perl.After installing the Perl
> > module with a lot of difficulty I am facing the following issue. I am
> > able to log-into the box but I don't get any results back for the
> > commands I am trying to run on the box.
> > If I use the same perl code to log-into another linux machine and do
> > an"ls" I get the result back with no problems at all. Here is the debug
> > message while trying to access the CLI-box and running the commands.
> >
> > Any Help will be really appreciated. I have been struck at the same
> > issue for about a month and my code is due soon and I have no clue how
> > to fix it.
>
> Showing your code would help.
>
> First, run the ssh from the command line:
>
> ssh machine ls
>
> Does that work for both machines?
------------------------------
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 V10 Issue 9964
***************************************