[30721] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1966 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 6 03:09:44 2008

Date: Thu, 6 Nov 2008 00:09: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           Thu, 6 Nov 2008     Volume: 11 Number: 1966

Today's topics:
    Re: A couple of questions regarding runtime generation  sln@netherlands.com
    Re: crisis Perl <Juha.Laiho@iki.fi>
    Re: hash array loop in sequence? <joe@inwap.com>
    Re: hash array loop in sequence? xhoster@gmail.com
    Re: hash array loop in sequence? <whynot@pozharski.name>
        new CPAN modules on Thu Nov  6 2008 (Randal Schwartz)
    Re: perl maximum memory <nospam-abuse@ilyaz.org>
    Re: Question on the length of a Scalar <joe@inwap.com>
        Substitution <v3gupta@gmail.com>
    Re: Telnet - How to not displayed something on web page <arnvel@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 05 Nov 2008 19:54:14 GMT
From: sln@netherlands.com
Subject: Re: A couple of questions regarding runtime generation of REGEXP's
Message-Id: <djt3h4hug8tlliml2q9iaso5gb3b8j9hm2@4ax.com>

On Wed, 05 Nov 2008 00:31:44 GMT, sln@netherlands.com wrote:

>On Tue, 04 Nov 2008 12:23:07 +0100, Michele Dondi <bik.mido@tiscalinet.it> wrote:
>
>>On Mon, 03 Nov 2008 23:01:35 GMT, sln@netherlands.com wrote:
>>
>>>In my opinion, s///g should be allowed by qr{} using the scoping block it was created
>>>in, and later correctly used (s///g) within the context of a block that invokes the engine.
>>>
>>>This may violate 'first-order object' of the language. But then why are code extensions allowed?
>>>qr/(?{ code })/ and what is the scoping for them? To me this looks like parsing issues and
>>>if allowed would would internally result in a dynamic code issue like eval.
>>>I don't that this 'code' extension isn't treated as a literal anyway.
>>
>>Do not misunderstand me, I'm all with you: would you write a Perl
>>extension that allows to treat substitutions as first order objects of
>>the language? I would cherish that... Unfortunately I *for one*
>>haven't the slightest idea of where one could begin!
>>
>>In the meanwhile we must be happy with a clumsier solution, like...
>>
>>>I don't know if invoking a 'sub' (/e) is going to be any better than having to
>>>parse through a passed in argument list for the proper form. In all cases, it looks
>>>like the replacement text cannot include special var's unles an eval is used
>>>at runtime.
>>>
>>>Can you give an example of your regex and a sub solution?
>>
>>... sure:
>>
>>	my %subst = ( regex => qr/.../, code => sub { ... } );
>>
>>And then you use that to perform the substitution. You may even make
>>that the core data of a class, thus allowing objects like $subst with
>>a suitable ->apply($string) method.
>>
>>
>>Michele
>
[snip]
>
>This is a relief for me though. Thanks alot...
>
[snip]
>

I settled on this lightweight class that handles the substution with some
variable type's. Still it is with minimal error checking to reduce overhead.
Added a few methods to generalize access, and it benchmarks pretty good.

See any potential problems or performance issues ?

sln

----------------------
use strict;
use warnings;

my $data = "This(1) is some data, this(2) gets substituted,
and so does this(3).";
my $tempdata = $data;

my $rxp = RxP->new (
	'regex' => qr/(\whis\(\d\))/si,
	'code'  => sub { print "code: \$1 = $1\n"; return 'That'; },
	'type'  => 'r'
);

# test apply, set/get_type methods
if (1)
{
	print "\n","-"x20,"\nData = $data\n\n";

	$rxp->set_type('s');
	if ($rxp->apply ($data)) {
		print "Apply '".$rxp->get_type."' worked, data = $data\n\n";
	}
	$rxp->set_type('r');
	if ($rxp->apply ($data)) {
		print "Apply '".$rxp->get_type."' worked, data = $data\n\n";
	}
	$rxp->set_type('g');
	if ($rxp->apply ($data)) {
		print "Apply '".$rxp->get_type."' worked, data = $data\n\n";
	}
}

# test direct call and search, replace, replace_g methods
if (1)
{
	$rxp->set_type('r');
	$data = $tempdata;
	print "\n","-"x20,"\nData = $data\n\n";

	if ($rxp->{'dflt_sub'}($rxp, $data)) {
		print "Direct {dflt_sub} worked, data = $data\n\n";
	}
	if ($rxp->search ($data)) {
		print "Search worked, data = $data\n\n";
	}
	if ($rxp->replace ($data)) {
		print "Replace worked, data = $data\n\n";
	}
	if ($rxp->replace_g ($data)) {
		print "Global replace worked, data = $data\n\n";
	}
}


package RxP;
use vars qw(@ISA);
@ISA = qw();

sub new
{
	my ($class, @args) = @_;
	my $self  = {
	  'dflt_sub' => \&search,
	  'type' => 's'
	};
	while (my ($name, $val) = splice (@args, 0, 2)) {
		if ('regex' eq lc $name) {
			$self->{'regex'} = $val;
		}
		elsif ('code' eq lc $name) {
			$self->{'code'} = $val;
		}
		elsif ('type' eq lc $name && $val =~ /(s|r|g)/i) {
			set_type ($self, $1);
		}
	}
	return bless ($self, $class);
}
sub get_type
{
	return $_[0]->{'type'};
}
sub set_type
{
	return 0 unless (defined $_[1]);
	if ($_[1] =~ /(s|r|g)/i) {
		$_[0]->{'dflt_sub'} = {
		   's' => \&search,
		   'r' => \&replace,
		   'g' => \&replace_g 
		}->{$1};
		$_[0]->{'type'} = $1;
		return 1;
	}
	return 0;
}
sub apply
{
	return 0 unless (defined $_[1]);
	return &{$_[0]->{'dflt_sub'}};
}
sub search
{
	return 0 unless (defined $_[1]);
	return $_[1] =~ /$_[0]->{'regex'}/;
}
sub replace
{
	return 0 unless (defined $_[1]);
	return $_[1] =~ s/$_[0]->{'regex'}/&{$_[0]->{'code'}}/e;
}
sub replace_g
{
	return 0 unless (defined $_[1]);
	return $_[1] =~ s/$_[0]->{'regex'}/&{$_[0]->{'code'}}/ge;
}

__END__

--------------------
Data = This(1) is some data, this(2) gets substituted,
and so does this(3).

Apply 's' worked, data = This(1) is some data, this(2) gets substituted,
and so does this(3).

code: $1 = This(1)
Apply 'r' worked, data = That is some data, this(2) gets substituted,
and so does this(3).

code: $1 = this(2)
code: $1 = this(3)
Apply 'g' worked, data = That is some data, That gets substituted,
and so does That.


--------------------
Data = This(1) is some data, this(2) gets substituted,
and so does this(3).

code: $1 = This(1)
Direct {dflt_sub} worked, data = That is some data, this(2) gets substituted,
and so does this(3).

Search worked, data = That is some data, this(2) gets substituted,
and so does this(3).

code: $1 = this(2)
Replace worked, data = That is some data, That gets substituted,
and so does this(3).

code: $1 = this(3)
Global replace worked, data = That is some data, That gets substituted,
and so does That.







------------------------------

Date: Wed, 05 Nov 2008 19:22:03 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: crisis Perl
Message-Id: <gesril$p70$1@ichaos2.ichaos-int>

sln@netherlands.com said:
>On Fri, 31 Oct 2008 16:27:03 GMT, Juha Laiho <Juha.Laiho@iki.fi> wrote:
>>As far as the code does what it is intended to do now, it is, stirctly
>>speaking, not a technical issue (which, I guess, would make it belong to
>>your domain), but instead it is an economic issue (and as such belongs
>>to your managers domain). What you could do would be to try and see
>>whether your manager understands the "debt" aspect of the situation
>>his decision is creating, and how much of this debt he is willing
>>to carry (and also pay the running interest for -- in more laborious
>>changes to the code).
>
>^^^^^^^
>This is not a good argument. The best you can do is what was intended.
>Nobody can get schizo about it and program place holders for what if's
>pathologically.

No, what I wrote about was not about putting in placeholders for
future enhancements. I wrote about having the code written in such
a shoddy way that each change starts to require enormous amounts
of testing, because you just cannot be sure what all is affected
by the change -- or having code that requires you to write layer
upon layer of special cases to cover for earlier bad design
decisions. Or code where "reuse" was made using cut&paste, instead
of modular, composable pieces -- where, to consistently make a single
change, you end up making the same change many times over.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Wed, 05 Nov 2008 12:43:43 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: hash array loop in sequence?
Message-Id: <E5idnT_vEqrgmI_UnZ2dnUVZ_rbinZ2d@comcast.com>

xhoster@gmail.com wrote:
> smallpond <smallpond@juno.com> wrote:
> 
>> foreach my $entry qw(name age sex phone city state country )
>> {
>>   print $entry ." ". $data{$entry} ."\n";
>> }
> 
> I was surprised that this works.  I thought the list of a foreach *had* to
> be in parentheses, and that the qw() wouldn't count as parentheses.

linux% perl -le 'foreach my $entry @ARGV {print $entry}' a b c d e
Array found where operator expected at -e line 1

As the error message says, it is looking for an operator, not just "(".
	-Joe


------------------------------

Date: 05 Nov 2008 20:54:20 GMT
From: xhoster@gmail.com
Subject: Re: hash array loop in sequence?
Message-Id: <20081105155453.042$FO@newsreader.com>

Joe Smith <joe@inwap.com> wrote:
> xhoster@gmail.com wrote:
> > smallpond <smallpond@juno.com> wrote:
> >
> >> foreach my $entry qw(name age sex phone city state country )
> >> {
> >>   print $entry ." ". $data{$entry} ."\n";
> >> }
> >
> > I was surprised that this works.  I thought the list of a foreach *had*
> > to be in parentheses, and that the qw() wouldn't count as parentheses.
>
> linux% perl -le 'foreach my $entry @ARGV {print $entry}' a b c d e
> Array found where operator expected at -e line 1
>
> As the error message says, it is looking for an operator, not just "(".

Is "(" really an operator?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: Wed, 05 Nov 2008 23:52:12 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: hash array loop in sequence?
Message-Id: <slrngh45ch.5bt.whynot@orphan.zombinet>

On 2008-11-05, Slickuser <slick.users@gmail.com> wrote:
*SKIP*
> If I got my hash array like this.  How can loop through in the order
> of name, age, sex, phone, city, state, country?

	print "$_ => $data{$_}\n"
	  foreach (qw( name age sex phone city state country ));

=begin off-topic

regarding time that passed for your post to be answered -- consider
getting real news-feed.

=end off-topic

-- 
Torvalds' goal for Linux is very simple: World Domination


------------------------------

Date: Thu, 6 Nov 2008 05:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Nov  6 2008
Message-Id: <K9wD6M.5B7@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.

Algorithm-FloodControl-1.91
http://search.cpan.org/~gugu/Algorithm-FloodControl-1.91/
Limit event processing to count/time ratio. 
----
Apache2-ASP-2.00_18
http://search.cpan.org/~johnd/Apache2-ASP-2.00_18/
ASP for Perl, reloaded. 
----
App-ZofCMS-Plugin-StyleSwitcher-0.0101
http://search.cpan.org/~zoffix/App-ZofCMS-Plugin-StyleSwitcher-0.0101/
CSS Style switcher plugin 
----
B-Hooks-Parser-0.05
http://search.cpan.org/~flora/B-Hooks-Parser-0.05/
Interface to perls parser variables 
----
B-Hooks-Parser-0.06
http://search.cpan.org/~flora/B-Hooks-Parser-0.06/
Interface to perls parser variables 
----
B-Hooks-Parser-0.07
http://search.cpan.org/~flora/B-Hooks-Parser-0.07/
Interface to perls parser variables 
----
CGI-Application-Gallery-1.08
http://search.cpan.org/~leocharre/CGI-Application-Gallery-1.08/
image gallery module 
----
CPAN-PackageDetails-0.13
http://search.cpan.org/~bdfoy/CPAN-PackageDetails-0.13/
Create or read 02.packages.details.txt.gz 
----
CPANPLUS-YACSmoke-0.24
http://search.cpan.org/~bingos/CPANPLUS-YACSmoke-0.24/
Yet Another CPANPLUS Smoke Tester 
----
Catalyst-Controller-RateLimit-0.22
http://search.cpan.org/~gugu/Catalyst-Controller-RateLimit-0.22/
Protect your site from robots 
----
ClearPress-267
http://search.cpan.org/~rpettett/ClearPress-267/
Simple, fresh & fruity MVC framework 
----
Coro-4.804
http://search.cpan.org/~mlehmann/Coro-4.804/
coroutine process abstraction 
----
DBIx-OO-0.0.7
http://search.cpan.org/~mishoo/DBIx-OO-0.0.7/
Database to Perl objects abstraction 
----
DBIx-OO-0.0.8
http://search.cpan.org/~mishoo/DBIx-OO-0.0.8/
Database to Perl objects abstraction 
----
Devel-CheckOS-1.49_01
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.49_01/
check what OS we're running on 
----
ExtUtils-Install-1.50_02
http://search.cpan.org/~yves/ExtUtils-Install-1.50_02/
install files from here to there 
----
ExtUtils-Install-1.50_03
http://search.cpan.org/~yves/ExtUtils-Install-1.50_03/
install files from here to there 
----
ExtUtils-Install-1.50_04
http://search.cpan.org/~yves/ExtUtils-Install-1.50_04/
install files from here to there 
----
Finance-Bank-LaPoste-5.00
http://search.cpan.org/~pixel/Finance-Bank-LaPoste-5.00/
Check your "La Poste" accounts from Perl 
----
HTML-Menu-TreeView-1.04
http://search.cpan.org/~lze/HTML-Menu-TreeView-1.04/
Create a HTML TreeView from scratch 
----
IO-Lambda-0.35
http://search.cpan.org/~karasik/IO-Lambda-0.35/
non-blocking I/O in lambda style 
----
LEOCHARRE-Dev-1.10
http://search.cpan.org/~leocharre/LEOCHARRE-Dev-1.10/
----
LaTeX-Table-0.9.7
http://search.cpan.org/~limaone/LaTeX-Table-0.9.7/
Perl extension for the automatic generation of LaTeX tables. 
----
Log-Syslog-UDP-0.09
http://search.cpan.org/~athomason/Log-Syslog-UDP-0.09/
Perl extension for very quickly sending syslog messages over UDP. 
----
Module-Release-2.00_06
http://search.cpan.org/~bdfoy/Module-Release-2.00_06/
Automate software releases 
----
Mojo-0.8005
http://search.cpan.org/~sri/Mojo-0.8005/
The Web In A Box! 
----
Net-SFTP-Foreign-1.45_06
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.45_06/
SSH File Transfer Protocol client 
----
OpenOffice-OODoc-2.106
http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.106/
The Perl Open OpenDocument Connector 
----
PDL-Graphics-OpenGL-Perl-OpenGL-0.01_03
http://search.cpan.org/~chm/PDL-Graphics-OpenGL-Perl-OpenGL-0.01_03/
v0.01_03 Perl OpenGL (POGL) module for PDL to display 3D data using OpenGL, FreeGLUT/GLUT, and GLX 
----
PDL-Graphics-OpenGL-Perl-OpenGL-0.01_04
http://search.cpan.org/~chm/PDL-Graphics-OpenGL-Perl-OpenGL-0.01_04/
v0.01_03 Perl OpenGL (POGL) module for PDL to display 3D data using OpenGL, FreeGLUT/GLUT, and GLX 
----
POE-Component-CPANPLUS-YACSmoke-1.52
http://search.cpan.org/~bingos/POE-Component-CPANPLUS-YACSmoke-1.52/
Bringing the power of POE to CPAN smoke testing. 
----
POE-Component-WebService-HtmlKitCom-FavIconFromImage-0.002
http://search.cpan.org/~zoffix/POE-Component-WebService-HtmlKitCom-FavIconFromImage-0.002/
non-blocking wrapper around WebService::HtmlKitCom::FavIconFromImage 
----
Padre-Plugin-TabAndSpace-0.05
http://search.cpan.org/~fayland/Padre-Plugin-TabAndSpace-0.05/
convert between space and tab within Padre 
----
Parse-Stallion-0.2
http://search.cpan.org/~arthur/Parse-Stallion-0.2/
Backtracking parser with during or after evaluation 
----
Postscript-HTML-Map-1.0001
http://search.cpan.org/~gbjk/Postscript-HTML-Map-1.0001/
----
Python-Decorator-0.01
http://search.cpan.org/~erwan/Python-Decorator-0.01/
Function composition at compile-time 
----
Python-Decorator-0.02
http://search.cpan.org/~erwan/Python-Decorator-0.02/
Function composition at compile-time 
----
Python-Decorator-0.03
http://search.cpan.org/~erwan/Python-Decorator-0.03/
Function composition at compile-time 
----
STAFService-0.25
http://search.cpan.org/~semuelf/STAFService-0.25/
Perl extension for writing STAF Services easily. 
----
Test-Declare-0.03
http://search.cpan.org/~nekokak/Test-Declare-0.03/
declarative testing 
----
Video-Filename-0.30
http://search.cpan.org/~behanw/Video-Filename-0.30/
Parse filenames for information about the video 
----
WWW-Scraper-ISBN-AmazonDE_Driver-0.043
http://search.cpan.org/~reneeb/WWW-Scraper-ISBN-AmazonDE_Driver-0.043/
Search driver for the (DE) Amazon online catalog. 
----
WWW-Search-DrugBank-0.03
http://search.cpan.org/~diberri/WWW-Search-DrugBank-0.03/
Access DrugBank's database of pharmaceuticals 
----
WebService-Nestoria-Search-1.14
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-1.14/
Perl interface to the Nestoria Search public API. 
----
Wx-Perl-DirTree-0.03
http://search.cpan.org/~reneeb/Wx-Perl-DirTree-0.03/
A directory tree widget for wxPerl 
----
XML-LibXML-1.68
http://search.cpan.org/~pajas/XML-LibXML-1.68/
Perl Binding for libxml2 
----
XML-LibXSLT-1.68
http://search.cpan.org/~pajas/XML-LibXSLT-1.68/
Interface to the gnome libxslt library 
----
excel2txt-0.04
http://search.cpan.org/~kclark/excel2txt-0.04/
convert Excel data to delimited text files 
----
libwww-perl-5.820
http://search.cpan.org/~gaas/libwww-perl-5.820/


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, 5 Nov 2008 21:13:32 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: perl maximum memory
Message-Id: <get29s$2pc1$1@agate.berkeley.edu>

[A complimentary Cc of this posting was NOT [per weedlist] sent to
Peter J. Holzer
<hjp-usenet2@hjp.at>], who wrote in article <slrngh39kn.819.hjp-usenet2@hrunkner.hjp.at>:
> For 64-bit processes the limit is theoretically 16 Exabytes, but that's
> well beyond the capabilities of current hardware. 

???  Well *within* capabilities of current hardware.  One ethernet
card, and you have *a possibility* of unlimited (read: limited only by
software) expansion of available disk space; which may be
memory-mapped.

So it is a question of money only.  Last time I checked, 2^32 bytes of
read/write storage costed about 40cents; the overhead to network it is
not large....  So it is less than $2B to get 2^64 bytes...

It may be much more cost-effective to have robotic CD/changer; do not
know price//relibility, though...

Yours,
Ilya


------------------------------

Date: Wed, 05 Nov 2008 22:25:13 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Question on the length of a Scalar
Message-Id: <RoGdndoln9RaEI_UnZ2dnUVZ_rrinZ2d@comcast.com>

Peter J. Holzer wrote:
> On 2008-10-22 21:31, xhoster@gmail.com <xhoster@gmail.com> wrote:
>> sln@netherlands.com wrote:
>>> I just have a simple question.
>>>
>>> When I call the length function on a scalar, is it read directly
>>> (ie: already know its length), or does it traverse the string
>>> counting its characters until it hits a nul terminator?
>> The first one.
> 
> That depends on the string. If it is a byte string, you are right.

No.  A scalar string in Perl has its length stored in the typeglob
as part of the variable's metadata.

perl
    $string = "=" x 80 . "\000" . "_" x 80 . "\000";
    die if length $string != 80+1+80+1;
    print "The string, with embedded nulls, is ", length $string, " bytes.\n";
    $string .= "\x{1234}";
    print "Adding one UTF-8 character, the length is now ", length $string, ".\n";
^D
The string, with embedded nulls, is 162 bytes.
Adding one UTF-8 character, the length is now 163.

> If it is a scalar string, the string must be traversed to count the
> characters.

Nope.  Perl knows exactly how many characters are in a string at all times.

> However, the result seems to be cached 

There is no "seems to be" about it.  The size of a scalar is stored
as part of the typeglob where it can be accessed _without_ traversing the string.

	-Joe


------------------------------

Date: Wed, 5 Nov 2008 22:17:37 -0800 (PST)
From: Vishal G <v3gupta@gmail.com>
Subject: Substitution
Message-Id: <97e0a0e1-4ae2-4a9a-beda-c644d654f25b@l33g2000pri.googlegroups.com>

Hi Guys,

A Simple Substitution Problem

    my $dna =
"***********acgtgcta*****atctgat******actgtaaa***tttt**cccc******ccccc******";

    # I want to replace asterisk(*) with dot(.) if 10 or more
asterisks occur together

    $dna =~ s/\*{10,}/./g;

    print "$dna\n";

    # output

    .acgtgcta*****atctgat******actgtaaa***tttt**cccc******ccccc******

    As you can see 10 or more asterisk are replaced with dot but what
I want is this

    ...........acgtgcta*****atctgat******actgtaaa***tttt**cccc******ccccc******


How to do it

Vishal


------------------------------

Date: Wed, 5 Nov 2008 11:32:02 -0800 (PST)
From: Lalo <arnvel@gmail.com>
Subject: Re: Telnet - How to not displayed something on web page
Message-Id: <80d2b657-db50-4bdf-8f09-bc75aa14134d@h23g2000prf.googlegroups.com>

On Nov 4, 6:13 pm, Ted Zlatanov <t...@lifelogs.com> wrote:
> On Tue, 4 Nov 2008 13:54:37 -0800 (PST) Lalo <arn...@gmail.com> wrote:
>
> L> I am using Expect wrapper in perl  telnet to machine and do ls -ltra
> L> on remote machine
>
> Have you tried Net::Telnet?  It makes the task much, much easier than
> the way you're doing it.
>
> L> my $var = param('VAR');
> L>   print "You have chosen :  $var.<br><br>\n";
> L>   print start_html;
> L>   if ($var eq "abc") {
> L>   print "\n<br>Your var is : $var: <br>\n";
> L>   print "\n<br> Telnet AA.BB.CC.DD 2100: <br><br>\n";
> L>   my $exp = new Expect;
> L>   my $command = 'telnet AA.BB.CC.DD 2100';
> L>   $exp->spawn($command) or die "Cannot spawn $command: $!\n";
> L>   print "<br>";
> L>   print end_html;
>
> L>   print "<br>\n";
>
> L>   $exp->send("cd /tmp\n");
> L>   $exp->send("ls -ltra > log2.log\n");
>
> L>   print start_html;
> L>   $exp->send("\x1d\n");
> L>   my $tel = $exp->expect(30, 'telnet>');
> L>   $exp->send("quit\r");
> L>   print end_html;
> L>   $exp->interact();
> L> }
>
> L> elsif ($var eq "def") {
>
> L> }
>
> Look at the Template module (AKA Template Toolkit), it will make the
> above much easier by letting you write a simple web page template you
> can fill in with your data.  It supports IF-THEN and FOREACH constructs.
>
> I'd suggest doing the work first (in an eval if possible), then
> generating the HTML.  Otherwise a problem in the telnet session code
> will break your page.
>
> Ted

Thank you Ted.

I'll take a look at.
To be honest, I haven't looked into it.

Thanks again,
Lalo


------------------------------

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 1966
***************************************


home help back first fref pref prev next nref lref last post