[30719] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1964 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 5 06:09:43 2008

Date: Wed, 5 Nov 2008 03:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Nov 2008     Volume: 11 Number: 1964

Today's topics:
    Re: A couple of questions regarding runtime generation  sln@netherlands.com
        creating an array of $n elements <samwyse@gmail.com>
    Re: creating an array of $n elements <vilain@NOspamcop.net>
    Re: creating an array of $n elements <jurgenex@hotmail.com>
    Re: creating an array of $n elements <jurgenex@hotmail.com>
    Re: creating an array of $n elements <someone@example.com>
    Re: creating an array of $n elements <cwilbur@chromatico.net>
    Re: creating an array of $n elements (fidokomik\)
        hash array loop in sequence? <slick.users@gmail.com>
    Re: hash array loop in sequence? <anfi@onet.eu>
        new CPAN modules on Wed Nov  5 2008 (Randal Schwartz)
    Re: Perl Presentation <brian.d.foy@gmail.com>
        Telnet - How to not displayed something on web page <arnvel@gmail.com>
    Re: Telnet - How to not displayed something on web page <tzz@lifelogs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

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

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

I'm in your debt. There is virtually no overhead in calling that
sub for the substitution, and it executes in context. There is no
comparison with eval, this is the way to go for me.

I will, and have already resigned that its the callers responsibility
to ensure proper regexp usage, so/and I am just providing the rope.

In my circumstances, its all about performance. Any added indirection,
calls/assignments, etc.. will mean hazard in my usage. I won't get into
the gory details unless you want to know.

Below, is raw isolated test code, in the case of method 2, no error checking.
I already have an object function that an array of regex/code sub's could be passed to
where it then operates on data highly bound to the object.

Introducing a new object, RegxProc in the simple case below, would aleviate parsing,
but an unknown object type might not be acessable. But would aleviate internal processing.
I could internalize the RegxProc in the existing class, providing a wrapper method I guess
but the caller could not specify search/replace/replace global without additional parameter
parsing.

This is a relief for me though. Thanks alot...

sln

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

use strict;
use warnings;

# method 1
# ------------
# my $data = "This is some data, this gets substituted";
# my $subst = {
# 	'regex' => qr/(\whis)/i,
# 	'code' => sub { print "$1\n"; return 'That'; }
# };
# $data =~ s/$subst->{'regex'}/ &{$subst->{'code'}}/ge;
# print "$data\n";


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

print "\nData = $data\n\n";

my $rxp = new RegxProc (
	'regex' => qr/(\whis\(\d\))/si,
	'code'  => sub { print "\ncode: \$1 = $1\n"; return 'That'; }
);
if ($rxp->search ($data)) {
	print "search worked\n";
}
if ($rxp->replace ($data)) {
	print "replace worked, data = $data\n";
}
if ($rxp->replace_g ($data)) {
	print "global replace worked, data = $data\n";
}

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

sub new
{
	my ($class, @args) = @_;
	my $self  = {};
	while (my ($name, $val) = splice (@args, 0, 2)) {
		if ('regex' eq lc $name) {
			$self->{regex} = $val;
		}
		elsif ('code' eq lc $name) {
			$self->{code} = $val;
		}
	}
	return bless ($self, $class);
}
sub search
{
	my $self = shift;
	return 0 unless (defined $_[0]);
	return $_[0] =~ /$self->{regex}/;
}
sub replace
{
	my $self = shift;
	return 0 unless (defined $_[0]);
	return $_[0] =~ s/$self->{regex}/&{$self->{code}}/e;
}
sub replace_g
{
	my $self = shift;
	return 0 unless (defined $_[0]);
	return $_[0] =~ s/$self->{regex}/&{$self->{code}}/ge;
}

__END__

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

search worked

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

code: $1 = this(2)

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






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

Date: Tue, 4 Nov 2008 19:31:41 -0800 (PST)
From: samwyse <samwyse@gmail.com>
Subject: creating an array of $n elements
Message-Id: <6f658211-73b6-4a3e-a461-28a75504345e@c2g2000pra.googlegroups.com>

In Python, I can say "7 * (1,)" to create a list of 7 items. If I need
a list in Perl with all elements initialized to the same value, is
there a one-liner?  The best I can come up with is "$a[$n] = 0; pop
@a;" which will give me an array of $n undefs, but it seems a bit
inefficient.  Any ideas?  Thanks.


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

Date: Tue, 04 Nov 2008 20:03:49 -0800
From: Michael Vilain <vilain@NOspamcop.net>
Subject: Re: creating an array of $n elements
Message-Id: <vilain-599817.20034904112008@feeder.motzarella.org>

In article 
<6f658211-73b6-4a3e-a461-28a75504345e@c2g2000pra.googlegroups.com>,
 samwyse <samwyse@gmail.com> wrote:

> In Python, I can say "7 * (1,)" to create a list of 7 items. If I need
> a list in Perl with all elements initialized to the same value, is
> there a one-liner?  The best I can come up with is "$a[$n] = 0; pop
> @a;" which will give me an array of $n undefs, but it seems a bit
> inefficient.  Any ideas?  Thanks.

what's wrong with a simple declaration with initialization?

@a = (0, 0, 0, 0, 0, 0, 0);

Or have I missed something?

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]




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

Date: Tue, 04 Nov 2008 20:39:59 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: creating an array of $n elements
Message-Id: <eq82h4lajpdf33alhjjh6qij9fo09cso94@4ax.com>

samwyse <samwyse@gmail.com> wrote:
> If I need
>a list in Perl with all elements initialized to the same value, is
>there a one-liner?  

perldoc perlop ==> Multiplicative Operators ==> x

       @ones = (1) x 80;           # a list of 80 1's

jue


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

Date: Tue, 04 Nov 2008 20:40:57 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: creating an array of $n elements
Message-Id: <dt82h4dkuoj65ti3pfu7mdfe9mmodttu8e@4ax.com>

Michael Vilain <vilain@NOspamcop.net> wrote:
>In article 
><6f658211-73b6-4a3e-a461-28a75504345e@c2g2000pra.googlegroups.com>,
> samwyse <samwyse@gmail.com> wrote:
>
>> In Python, I can say "7 * (1,)" to create a list of 7 items. If I need
>> a list in Perl with all elements initialized to the same value, is
>> there a one-liner?  The best I can come up with is "$a[$n] = 0; pop
>> @a;" which will give me an array of $n undefs, but it seems a bit
>> inefficient.  Any ideas?  Thanks.
>
>what's wrong with a simple declaration with initialization?
>
>@a = (0, 0, 0, 0, 0, 0, 0);
>
>Or have I missed something?

@a = (0) x 7;

seems to be easier on the eyes.

jue


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

Date: Tue, 04 Nov 2008 20:43:55 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: creating an array of $n elements
Message-Id: <dw9Qk.22985$7o4.521@newsfe01.iad>

samwyse wrote:
> In Python, I can say "7 * (1,)" to create a list of 7 items. If I need
> a list in Perl with all elements initialized to the same value, is
> there a one-liner?  The best I can come up with is "$a[$n] = 0; pop
> @a;" which will give me an array of $n undefs, but it seems a bit
> inefficient.  Any ideas?  Thanks.

$ perl -le'
use Data::Dumper;
my $n = 7;
my @a = ( undef ) x $n;
print Dumper \@a;
'
$VAR1 = [
           undef,
           undef,
           undef,
           undef,
           undef,
           undef,
           undef
         ];


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, 04 Nov 2008 23:48:54 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: creating an array of $n elements
Message-Id: <86vdv2n5ft.fsf@mithril.chromatico.net>

>>>>> "s" == samwyse  <samwyse@gmail.com> writes:

    s> If I need a list in Perl with all elements initialized to the
    s> same value, is there a one-liner?

Look at the x operator in perldoc perlop.

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Wed, 5 Nov 2008 09:16:36 +0100
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: creating an array of $n elements
Message-Id: <gerks9$1s2r$1@ns.felk.cvut.cz>

samwyse wrote:
> In Python, I can say "7 * (1,)" to create a list of 7 items. If I need
> a list in Perl with all elements initialized to the same value, is
> there a one-liner?  The best I can come up with is "$a[$n] = 0; pop
> @a;" which will give me an array of $n undefs, but it seems a bit
> inefficient.  Any ideas?  Thanks.

@a = (0)x7; # for array of 7 elements
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Tue, 4 Nov 2008 23:55:13 -0800 (PST)
From: Slickuser <slick.users@gmail.com>
Subject: hash array loop in sequence?
Message-Id: <d8b88faf-d729-40ca-8cc5-1cd8ee74c7f7@c36g2000prc.googlegroups.com>

my %data = (
	"name"		=> "BOB",
	"age"		=> 35,
	"sex"		=> "M",
	"phone"		=> "555-5555",
	"city"		=> "LA",
	"state"		=> "CA",
	"country"	=> "US"
);

foreach my $entry (keys %data)
{
	print $entry ." ". $data{$entry} ."\n";
	##can't use sort keys or values
}


If I got my hash array like this.
How can loop through in the order of name, age, sex, phone, city,
state, country?


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

Date: Wed, 05 Nov 2008 09:11:43 +0100
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: hash array loop in sequence?
Message-Id: <k7vfyrw878@carol.brudna.chmurka.net>

Slickuser <slick.users@gmail.com> wrote:

> my %data = (
> 	"name"		=> "BOB",
> 	"age"		=> 35,
> 	"sex"		=> "M",
> 	"phone"		=> "555-5555",
> 	"city"		=> "LA",
> 	"state"		=> "CA",
> 	"country"	=> "US"
> );
>
> foreach my $entry (keys %data)
> {
> 	print $entry ." ". $data{$entry} ."\n";
> 	##can't use sort keys or values
> }
>
>
> If I got my hash array like this.
> How can loop through in the order of name, age, sex, phone, city,
> state, country?

Have you considered using (simple) SQL database? e.g. SQLite
see DBD::SQLite on CPAN.org

If you want only one order of entries then consider using btree tied
hashes supported by DB_File module.

-- 
[pl>en Andrew] Andrzej Adam Filip : anfi@onet.eu : anfi@xl.wp.pl
We don't need no education, we don't need no thought control.
  -- Pink Floyd


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

Date: Wed, 5 Nov 2008 05:42:23 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Nov  5 2008
Message-Id: <K9uIIn.ons@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.

AI-Genetic-Pro-0.22
http://search.cpan.org/~strzelec/AI-Genetic-Pro-0.22/
Efficient genetic algorithms for professional purpose. 
----
AnyEvent-Mojo-0.5
http://search.cpan.org/~melo/AnyEvent-Mojo-0.5/
Run Mojo apps using AnyEvent framework 
----
Apache2-ASP-2.00_16
http://search.cpan.org/~johnd/Apache2-ASP-2.00_16/
ASP for Perl, reloaded. 
----
Apache2-ASP-2.00_17
http://search.cpan.org/~johnd/Apache2-ASP-2.00_17/
ASP for Perl, reloaded. 
----
App-Benchmark-0.02
http://search.cpan.org/~marcel/App-Benchmark-0.02/
Output your benchmarks as test diagnostics 
----
App-Benchmark-Accessors-0.02
http://search.cpan.org/~marcel/App-Benchmark-Accessors-0.02/
benchmark accessor generators 
----
App-Benchmark-Accessors-0.03
http://search.cpan.org/~marcel/App-Benchmark-Accessors-0.03/
benchmark accessor generators 
----
B-Hooks-Parser-0.04
http://search.cpan.org/~flora/B-Hooks-Parser-0.04/
Interface to perls parser variables 
----
CGI-IDS-1.00
http://search.cpan.org/~hinnerk/CGI-IDS-1.00/
PerlIDS - Perl Website Intrusion Detection System (XSS, CSRF, SQLI, LFI etc.) 
----
CGI-IDS-1.01
http://search.cpan.org/~hinnerk/CGI-IDS-1.01/
PerlIDS - Perl Website Intrusion Detection System (XSS, CSRF, SQLI, LFI etc.) 
----
CGI-Session-ID-sha-1.01
http://search.cpan.org/~desoto/CGI-Session-ID-sha-1.01/
CGI::Session ID driver for generating SHA-1 based IDs 
----
CPAN-Mini-0.572
http://search.cpan.org/~rjbs/CPAN-Mini-0.572/
create a minimal mirror of CPAN 
----
Catalyst-Manual-5.7014
http://search.cpan.org/~rjbs/Catalyst-Manual-5.7014/
The Catalyst developer's manual 
----
CatalystX-CMS-0.001
http://search.cpan.org/~karman/CatalystX-CMS-0.001/
drop-in content management system 
----
CatalystX-self-0.01
http://search.cpan.org/~jmmills/CatalystX-self-0.01/
A customized self for Catalyst controllers 
----
Collection-0.40
http://search.cpan.org/~zag/Collection-0.40/
Collections framework for to CRUD data or objects. 
----
Collection-0.41
http://search.cpan.org/~zag/Collection-0.41/
Collections framework for to CRUD data or objects. 
----
Crypt-Rijndael-1.07_02
http://search.cpan.org/~bdfoy/Crypt-Rijndael-1.07_02/
Crypt::CBC compliant Rijndael encryption module 
----
DBIx-Class-RandomColumns-0.003000
http://search.cpan.org/~graf/DBIx-Class-RandomColumns-0.003000/
Implicit random columns 
----
DBIx-StORM-0.11
http://search.cpan.org/~lukeross/DBIx-StORM-0.11/
Perl extension for object-relational mapping 
----
DBM-Deep-1.0014
http://search.cpan.org/~rkinyon/DBM-Deep-1.0014/
A pure perl multi-level hash/array DBM that supports transactions 
----
Data-Util-0.11
http://search.cpan.org/~gfuji/Data-Util-0.11/
A selection of utilities for data and data types 
----
Devel-SearchINC-1.36
http://search.cpan.org/~marcel/Devel-SearchINC-1.36/
loading Perl modules from their development dirs 
----
Device-Jtag-USB-FTCJTAG-0.11
http://search.cpan.org/~tdeitrich/Device-Jtag-USB-FTCJTAG-0.11/
Perl extension for communicating with JTAG devices using the FTDI FTCJTAG driver. 
----
Digest-Skein-0.00_02
http://search.cpan.org/~radek/Digest-Skein-0.00_02/
Perl interface to the Skein digest algorithm 
----
Dynamic-Loader-1.06
http://search.cpan.org/~alexmass/Dynamic-Loader-1.06/
call a script without to know where is his location. 
----
File-Find-Similars-2.04.1
http://search.cpan.org/~suntong/File-Find-Similars-2.04.1/
Fast similar-files finder 
----
File-Path-2.06_08
http://search.cpan.org/~dland/File-Path-2.06_08/
Create or remove directory trees 
----
File-Tabular-0.72
http://search.cpan.org/~dami/File-Tabular-0.72/
searching and editing flat tabular files 
----
HTML-FillInForm-Lite-1.03
http://search.cpan.org/~gfuji/HTML-FillInForm-Lite-1.03/
Fills in HTML forms with data 
----
HTTP-Session-0.08
http://search.cpan.org/~tokuhirom/HTTP-Session-0.08/
simple session 
----
Imager-Filter-FishEye-0.01
http://search.cpan.org/~tokuhirom/Imager-Filter-FishEye-0.01/
fisheye filter for Imager 
----
Imager-Filter-FishEye-0.02
http://search.cpan.org/~tokuhirom/Imager-Filter-FishEye-0.02/
fisheye filter for Imager 
----
JiftyX-ModelHelpers-0.22
http://search.cpan.org/~gugod/JiftyX-ModelHelpers-0.22/
Make it simpler to fetch records in Jifty. 
----
Log-Syslog-UDP-0.08
http://search.cpan.org/~athomason/Log-Syslog-UDP-0.08/
Perl extension for very quickly sending syslog messages over UDP. 
----
Mail-Builder-Simple-0.02
http://search.cpan.org/~teddy/Mail-Builder-Simple-0.02/
Send UTF-8 HTML and text email with attachments and inline images, eventually using templates 
----
Module-Release-2.00_05
http://search.cpan.org/~bdfoy/Module-Release-2.00_05/
Automate software releases 
----
Mojo-0.8.3
http://search.cpan.org/~sri/Mojo-0.8.3/
The Web In A Box! 
----
Mojo-0.8.4
http://search.cpan.org/~sri/Mojo-0.8.4/
The Web In A Box! 
----
Net-Arping-0.03_01
http://search.cpan.org/~radek/Net-Arping-0.03_01/
Ping remote host by ARP packets 
----
Net-SFTP-Foreign-1.45_05
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.45_05/
SSH File Transfer Protocol client 
----
Net-Twitter-Search-0.07
http://search.cpan.org/~shiny/Net-Twitter-Search-0.07/
Twitter Search 
----
News-Search-1.15
http://search.cpan.org/~suntong/News-Search-1.15/
Usenet news searching toolkit 
----
PDF-API2-0.72
http://search.cpan.org/~areibens/PDF-API2-0.72/
A Perl Module Chain to faciliate the Creation and Modification of High-Quality "Portable Document Format (aka. PDF)" Files. 
----
PDL-2.4.3_05
http://search.cpan.org/~chm/PDL-2.4.3_05/
the Perl Data Language 
----
Padre-Plugin-CPAN-0.01
http://search.cpan.org/~fayland/Padre-Plugin-CPAN-0.01/
CPAN in Padre 
----
Padre-Plugin-PluginHelper-0.01
http://search.cpan.org/~fayland/Padre-Plugin-PluginHelper-0.01/
make building Padre plugin easy 
----
Padre-Plugin-PluginHelper-0.02
http://search.cpan.org/~fayland/Padre-Plugin-PluginHelper-0.02/
make building Padre plugin easy 
----
Padre-Plugin-TabAndSpace-0.04
http://search.cpan.org/~fayland/Padre-Plugin-TabAndSpace-0.04/
convert between space and tab within Padre 
----
RT-Extension-MandatorySubject-0.01
http://search.cpan.org/~elacour/RT-Extension-MandatorySubject-0.01/
Enforce users to fill the subject when creating a ticket 
----
Rose-DBx-Object-MoreHelpers-0.04
http://search.cpan.org/~karman/Rose-DBx-Object-MoreHelpers-0.04/
more mixin helpers for RDBO 
----
Rose-DBx-Object-MoreHelpers-0.05
http://search.cpan.org/~karman/Rose-DBx-Object-MoreHelpers-0.05/
more mixin helpers for RDBO 
----
Set-Array-0.18
http://search.cpan.org/~rsavage/Set-Array-0.18/
Arrays as objects with lots of handy methods (including Set comparisons) and support for method chaining. 
----
TVDB-API-0.30
http://search.cpan.org/~behanw/TVDB-API-0.30/
API to www.thetvdb.com 
----
Tk-804.028_501
http://search.cpan.org/~srezic/Tk-804.028_501/
a graphical user interface toolkit for Perl 
----
WebService-Cath-FuncNet-0.04
http://search.cpan.org/~isillitoe/WebService-Cath-FuncNet-0.04/
Interface to the CATH FuncNet webservice 
----
Wx-Perl-Dialog-0.02
http://search.cpan.org/~szabgab/Wx-Perl-Dialog-0.02/
Abstract dialog class for simple dialog creation 
----
XML-Feed-0.3
http://search.cpan.org/~simonw/XML-Feed-0.3/
Syndication feed parser and auto-discovery 
----
XML-LibXML-1.67
http://search.cpan.org/~pajas/XML-LibXML-1.67/
Perl Binding for libxml2 
----
XML-LibXSLT-1.67
http://search.cpan.org/~pajas/XML-LibXSLT-1.67/
Interface to the gnome libxslt library 


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, 05 Nov 2008 02:07:37 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: Perl Presentation
Message-Id: <051120080207371877%brian.d.foy@gmail.com>

In article <868wrzo3x6.fsf@mithril.chromatico.net>, Charlton Wilbur
<cwilbur@chromatico.net> wrote:

> >>>>> "cc" == cartercc  <cartercc@gmail.com> writes:
> 
>     cc> I also have an advanced degree in SW and will finish my PhD in
>     cc> SW next year (I hope) and can tell you from experience that Perl
>     cc> and academics do not mix.
> 
> I expect the numerous academics who actually use Perl (Damian Conway,
> for one)

Damian's Dead Languages talk tells you why he wasn't fit for academia
and mostly isn't in that world anymore. Be careful what you want to
make other people say :)


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

Date: Tue, 4 Nov 2008 13:54:37 -0800 (PST)
From: Lalo <arnvel@gmail.com>
Subject: Telnet - How to not displayed something on web page
Message-Id: <a39af0c9-6665-4368-9a89-2e8af9dce6c2@z6g2000pre.googlegroups.com>


Hi,

I am using Expect wrapper in perl  telnet to machine and do ls -ltra
on remote machine

Everything work fine and I can see the following on my web page :

******************************************************************************
You have chosen : abc.


Your var is : abc:

Telnet AA.BB.CC.DD 2100:



cd /tmp ls -ltra > log2.log ^] Trying AA.BB.CC.DD 2100... Connected to
AA.BB.CC.DD 2100. Escape character is '^]'. telnet> quit Connection
closed.
*********************************************************************



The "problem" is I don't want that portion  "cd /tmp ls -ltra >
log2.log ^]" is displayed on web page, I would like that that part be
skipped and not dispayed somehow.

I thought that command Print_start print_end will handle that, but
obviously not.
Below is source code.

Thanks in advance for any help/suggestions.



***************************************************************************
#!/usr/bin/perl -w
use Expect;

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict;

print header;

my $exp = new Expect;



my $var = param('VAR');
	print "You have chosen :  $var.<br><br>\n";
	print start_html;
	if ($var eq "abc") {
	print "\n<br>Your var is : $var: <br>\n";
	print "\n<br> Telnet AA.BB.CC.DD 2100: <br><br>\n";
	my $exp = new Expect;
	my $command = 'telnet AA.BB.CC.DD 2100';
	$exp->spawn($command) or die "Cannot spawn $command: $!\n";
	print "<br>";
	print end_html;

	print "<br>\n";

	$exp->send("cd /tmp\n");
	$exp->send("ls -ltra > log2.log\n");


	print start_html;
	$exp->send("\x1d\n");
	my $tel = $exp->expect(30, 'telnet>');
	$exp->send("quit\r");
	print end_html;
	$exp->interact();
}

elsif ($var eq "def") {


}


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

Date: Tue, 04 Nov 2008 17:13:39 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Telnet - How to not displayed something on web page
Message-Id: <86tzanqe3g.fsf@lifelogs.com>

On Tue, 4 Nov 2008 13:54:37 -0800 (PST) Lalo <arnvel@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


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

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


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