[31242] in Perl-Users-Digest
Perl-Users Digest, Issue: 2487 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 21 18:09:44 2009
Date: Sun, 21 Jun 2009 15:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 21 Jun 2009 Volume: 11 Number: 2487
Today's topics:
a evaluation of Google-code-prettify <xahlee@gmail.com>
Re: a evaluation of Google-code-prettify greymausg@mail.com
new CPAN modules on Sun Jun 21 2009 (Randal Schwartz)
Re: Reading perl substitute expressions from a file <tadmc@seesig.invalid>
Re: Reading perl substitute expressions from a file <ben@morrow.me.uk>
Re: Reading perl substitute expressions from a file <jurgenex@hotmail.com>
Re: Reading perl substitute expressions from a file <vparseval@gmail.com>
Re: Reading perl substitute expressions from a file <cartercc@gmail.com>
Re: Reading perl substitute expressions from a file <derykus@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Jun 2009 17:26:13 -0700 (PDT)
From: Xah Lee <xahlee@gmail.com>
Subject: a evaluation of Google-code-prettify
Message-Id: <e0c61c18-fb6c-4cf8-9c23-a14b26620435@k17g2000prn.googlegroups.com>
For those of you interested in the Google tech of syntax coloring
source code in html on the fly using javascript, i've spent few hours
for a evaluation. See:
=E2=80=A2 Google-code-prettify Examples
http://xahlee.org/js/google-code-prettify/index.html
Xah
=E2=88=91 http://xahlee.org/
=E2=98=84
------------------------------
Date: 21 Jun 2009 10:58:36 GMT
From: greymausg@mail.com
Subject: Re: a evaluation of Google-code-prettify
Message-Id: <slrnh3s2on.jmu.greymausg@maushome.org>
On 2009-06-21, Xah Lee <xahlee@gmail.com> wrote:
> For those of you interested in the Google tech of syntax coloring
> source code in html on the fly using javascript, i've spent few hours
> for a evaluation. See:
>
> • Google-code-prettify Examples
> http://xahlee.org/js/google-code-prettify/index.html
>
> Xah
> ∑ http://xahlee.org/
>
> ☄
Tah for the news.
--
Greymaus
.
.
...
------------------------------
Date: Sun, 21 Jun 2009 04:42:36 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Jun 21 2009
Message-Id: <KLKnr0.1o73@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.
B-Foreach-Iterator-0.06
http://search.cpan.org/~gfuji/B-Foreach-Iterator-0.06/
Manipulates foreach iterators
----
Bot-BasicBot-Pluggable-0.74
http://search.cpan.org/~mdom/Bot-BasicBot-Pluggable-0.74/
extended simple IRC bot for pluggable modules
----
Coro-Mysql-1.0
http://search.cpan.org/~mlehmann/Coro-Mysql-1.0/
let other threads run while doing mysql requests
----
DBIx-Class-ResultSet-RecursiveUpdate-0.010
http://search.cpan.org/~zby/DBIx-Class-ResultSet-RecursiveUpdate-0.010/
like update_or_create - but recursive
----
DBIx-Class-ResultSet-RecursiveUpdate-v0.009
http://search.cpan.org/~zby/DBIx-Class-ResultSet-RecursiveUpdate-v0.009/
like update_or_create - but recursive
----
Date-WeekOfYear-1.03
http://search.cpan.org/~gng/Date-WeekOfYear-1.03/
Simple routine to return the week of the year (as well as the year)
----
Dist-Zilla-Plugin-Prepender-0.1.0
http://search.cpan.org/~jquelin/Dist-Zilla-Plugin-Prepender-0.1.0/
prepend lines at the top of your perl files
----
Dist-Zilla-Plugin-Prepender-0.1.1
http://search.cpan.org/~jquelin/Dist-Zilla-Plugin-Prepender-0.1.1/
prepend lines at the top of your perl files
----
Dist-Zilla-Plugin-Prepender-0.1.2
http://search.cpan.org/~jquelin/Dist-Zilla-Plugin-Prepender-0.1.2/
prepend lines at the top of your perl files
----
Exception-SEH-0.01005
http://search.cpan.org/~randir/Exception-SEH-0.01005/
rich try/catch/finally semantics without source filtering
----
Finance-Bank-mBank-0.02
http://search.cpan.org/~bjakubski/Finance-Bank-mBank-0.02/
Check mBank account balance
----
Foorum-1.000009
http://search.cpan.org/~fayland/Foorum-1.000009/
forum system based on Catalyst
----
Graph-Easy-StateMachine-0.04
http://search.cpan.org/~davidnico/Graph-Easy-StateMachine-0.04/
create a FSA framework from a Graph::Easy graph
----
HTML-FormHandler-0.24
http://search.cpan.org/~gshank/HTML-FormHandler-0.24/
form handler written in Moose
----
HTML-FormHandler-0.25
http://search.cpan.org/~gshank/HTML-FormHandler-0.25/
form handler written in Moose
----
HTML-Parser-3.61
http://search.cpan.org/~gaas/HTML-Parser-3.61/
HTML parser class
----
Lingua-EN-Bigram-0.01
http://search.cpan.org/~emorgan/Lingua-EN-Bigram-0.01/
Calculate significant two-word phrases based on frequency and/or T-Score
----
LotusNotes-LoadExport-1.01
http://search.cpan.org/~gng/LotusNotes-LoadExport-1.01/
A module to automate the processing of LotusNotes text export files
----
Math-Evol-1.10
http://search.cpan.org/~pjb/Math-Evol-1.10/
Evolution search optimisation
----
Method-Signatures-20090620
http://search.cpan.org/~mschwern/Method-Signatures-20090620/
method declarations with signatures and no source filter
----
Net-DigitalNZ-0.03
http://search.cpan.org/~shiny/Net-DigitalNZ-0.03/
----
Net-DigitalNZ-0.04
http://search.cpan.org/~shiny/Net-DigitalNZ-0.04/
----
Net-DigitalNZ-0.10
http://search.cpan.org/~shiny/Net-DigitalNZ-0.10/
----
Net-DigitalNZ-0.11
http://search.cpan.org/~shiny/Net-DigitalNZ-0.11/
----
Net-DigitalNZ-0.12
http://search.cpan.org/~shiny/Net-DigitalNZ-0.12/
Perl interface to digitalnz.org 's open data api.
----
Net-DigitalNZ-0.14
http://search.cpan.org/~shiny/Net-DigitalNZ-0.14/
Perl interface to digitalnz.org 's open data api.
----
Net-DigitalNZ-0.15
http://search.cpan.org/~shiny/Net-DigitalNZ-0.15/
Perl interface to digitalnz.org 's open data api.
----
Net-Generatus-0.40
http://search.cpan.org/~shiny/Net-Generatus-0.40/
Get random status message from generatus.com
----
Net-IMAP-Simple-1.1899_06
http://search.cpan.org/~jettero/Net-IMAP-Simple-1.1899_06/
Perl extension for simple IMAP account handling.
----
Net-Redmine-0.07
http://search.cpan.org/~gugod/Net-Redmine-0.07/
A mechanized-based programming API against redmine server.
----
Net-Twitter-Lite-0.03000
http://search.cpan.org/~mmims/Net-Twitter-Lite-0.03000/
A perl interface to the Twitter API
----
Net-Twitter-Lite-0.03001
http://search.cpan.org/~mmims/Net-Twitter-Lite-0.03001/
A perl interface to the Twitter API
----
PApp-SQL-1.04
http://search.cpan.org/~mlehmann/PApp-SQL-1.04/
absolutely easy yet fast and powerful sql access.
----
PHP-Serialization-0.32
http://search.cpan.org/~bobtfish/PHP-Serialization-0.32/
simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa.
----
POE-Component-CPAN-Reporter-0.06
http://search.cpan.org/~bingos/POE-Component-CPAN-Reporter-0.06/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-YACSmoke-1.36
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-1.36/
Bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPANPLUS-YACSmoke-1.60
http://search.cpan.org/~bingos/POE-Component-CPANPLUS-YACSmoke-1.60/
Bringing the power of POE to CPAN smoke testing.
----
POE-Filter-SimpleHTTP-0.091710
http://search.cpan.org/~nperez/POE-Filter-SimpleHTTP-0.091710/
A simple client/server suitable HTTP filter
----
Padre-Plugin-Perl6-0.43
http://search.cpan.org/~azawawi/Padre-Plugin-Perl6-0.43/
Padre plugin for Perl6
----
Padre-Plugin-SpellCheck-1.1.2
http://search.cpan.org/~jquelin/Padre-Plugin-SpellCheck-1.1.2/
check spelling in Padre
----
Provision-Unix-0.57
http://search.cpan.org/~msimerson/Provision-Unix-0.57/
provision accounts on unix systems
----
Term-Sk-0.01
http://search.cpan.org/~keichner/Term-Sk-0.01/
Perl extension for displaying a progress indicator on a terminal.
----
Test-Weaken-2.003_004
http://search.cpan.org/~jkegl/Test-Weaken-2.003_004/
Test that freed memory objects were, indeed, freed
----
Text-Editor-Easy-0.48
http://search.cpan.org/~grommier/Text-Editor-Easy-0.48/
A perl module to edit perl code with syntax highlighting and more.
----
XML-Reader-0.10
http://search.cpan.org/~keichner/XML-Reader-0.10/
Reading XML and providing path information based on a pull-parser.
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: Sat, 20 Jun 2009 07:33:38 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <slrnh3plkq.jad.tadmc@tadmc30.sbcglobal.net>
Luc Leemans <l.leemans@cox.net> wrote:
> A simple substitution in perl is done by
> $variable =~ s/string1/string2/i;
> $variable =~ s/string3/string4/g;
> print $variable;
>
> This works fine but I would have to tailor the program for each specific
> case.
>
> I would like to put these is a file D:/TEMP/perlString.txt and then write a
> perl program to read and execute them.
> Is it even possible?
Sure.
But treating data as if it were code is messy and often dangerous.
So don't put the s///'s in a data file, put them in a code file:
----------------------------
# perlString.pl
sub apply_substitutions {
for ( $_[0] ) {
s/string1/string2/i;
s/string3/string4/g;
}
}
1;
----------------------------
Then your main program would look something like:
----------------------------
#!/usr/bin/perl
use warnings;
use strict;
require 'perlString.pl';
my $var = "String100 and string3 followed by string300\n";
print 'before: ', $var;
apply_substitutions($var);
print 'after : ', $var;
----------------------------
But I'm not a big fan of invisible side-effects like that.
I'd prefer to make it clear that I'm changing the value of $val, so:
----------------------------
# perlString.pl
sub apply_substitutions {
local $_ = shift;
s/string1/string2/i;
s/string3/string4/g;
return $_;
}
1;
----------------------------
And change this line in the main program:
$var = apply_substitutions($var);
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 20 Jun 2009 14:04:57 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <pc3vg6-e17.ln1@osiris.mauzo.dyndns.org>
Quoth "Luc Leemans" <l.leemans@cox.net>:
> A simple substitution in perl is done by
> $variable =~ s/string1/string2/i;
> $variable =~ s/string3/string4/g;
> print $variable;
>
> This works fine but I would have to tailor the program for each specific
> case.
>
> I would like to put these is a file D:/TEMP/perlString.txt and then write a
> perl program to read and execute them.
You need to parse the s///s yourself and pass the pieces to perl.
Something like (untested)
my @substs = qw{
s/regex1/string2/i
s/regex3/string4/g
};
my $variable;
for (@substs) {
my (undef, $pat, $str, $flags) =
/ s (.) ([^\1]*) \1 ([^\1]*) \1 ([msixg]*) /x
or die "invalid substitution '$_'";
# /g can't go inside (?:), so we must apply it ourselves
my $global = $flags =~ tr/g//d;
my $rx = "(?$flags:$pat)";
if ($global) {
$variable =~ s/$rx/$str/g;
}
else {
$variable =~ s/$rx/$str/;
}
}
Note that this won't recognise /o or /c (or 5.10's /p), as they're not
likely to be useful, and that it doesn't honour matching delimiters like
s{}{}. Modifying it to support these wouldn't be difficult. Also note
that I have renamed 'string1' to 'regex1', as it isn't a string. If you
want it to be a string, then you can quote it like
my $rx = "(?$flags:\Q$pat\E)";
Ben
------------------------------
Date: Sat, 20 Jun 2009 08:06:30 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <adup35d2gknae973ks4bb7gjb3e0q969bu@4ax.com>
"Luc Leemans" <l.leemans@cox.net> wrote:
>A simple substitution in perl is done by
> $variable =~ s/string1/string2/i;
> $variable =~ s/string3/string4/g;
> print $variable;
>
>This works fine but I would have to tailor the program for each specific
>case.
>
>I would like to put these is a file D:/TEMP/perlString.txt and then write a
>perl program to read and execute them.
>
>I have tried something like this but have been unsuccessful.
>Is it even possible?
>
>Basic logic I tried:
>
>my $inFile= "D:/TEMP/perlString.txt";
>open(INFILEH, $inFile);
>while (<INFILEH>)
>{
> chomp;
> $perlExpr = $_;
> $variable =~ $perlExpr;
You are confusing code and data. You are reading data from the file and
are trying to execute it as code.
Yes, technically this is possible using eval(), but be strongly warned:
it has its quirks and using eval() easily opens security holes as big as
a barn door.
A much better approch would be not trying to store the code in the
configuration file but only the data itself, i.e. the pattern and
replacement text for the s/// command and then use
s/$pattern/$replacement/;
jue
------------------------------
Date: Sun, 21 Jun 2009 11:03:10 +0000 (UTC)
From: Tassilo von Parseval <vparseval@gmail.com>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <h1l41e$a4i$1@news.eternal-september.org>
Thus spake Tad J McClellan:
> apply_substitutions($var);
> print 'after : ', $var;
> ----------------------------
>
>
> But I'm not a big fan of invisible side-effects like that.
>
> I'd prefer to make it clear that I'm changing the value of $val, so:
>
> ----------------------------
> # perlString.pl
>
> sub apply_substitutions {
> local $_ = shift;
Or, since we're in perl-5.10 land by now:
my $_ = shift;
> s/string1/string2/i;
> s/string3/string4/g;
>
> return $_;
> }
>
> 1;
> ----------------------------
>
>
> And change this line in the main program:
>
> $var = apply_substitutions($var);
Cheers,
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 20 Jun 2009 06:29:24 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <1a548a66-05f6-4567-8b11-dba576ffe684@l28g2000vba.googlegroups.com>
On Jun 20, 2:32=A0am, "Luc Leemans" <l.leem...@cox.net> wrote:
> A simple substitution in perl is done by
> =A0 $variable =3D~ s/string1/string2/i;
> =A0 $variable =3D~ s/string3/string4/g;
> =A0 print $variable;
>
> This works fine but I would have to tailor the program for each specific
> case.
>
> I would like to put these is a file D:/TEMP/perlString.txt and then write=
a
> perl program to read and execute them.
The obvious approach is to create a text configuration file, like
this:
Key1 Value1
Key2 Value2
etc.
In your program, read in the configuration file, create a hash
$CONFIG, and populate the hash like this:
foreach line in the config file:
my ($key, $value) =3D split;
$CONFIG{$key} =3D $value;
The you can substitute using $CONFIG{$key1} for $string1, and so on.
Alternatively, I have written scripts for this in Erlang and Lisp, but
not Perl, so you will have to do the bulk of the work. The idea is to
write a function that returns a function, so that when you call it, it
returns behavior rather than data. I understand that this is certainly
doable in Perl, but I haven't done it. Read Higher Order Perl by Mark
Jason Dominus. You can get a free copy at
http://hop.perl.plover.com/
but buy the dead tree version to encourage authors.
Here is an example (in Erlang) of what I'm talking about, taken from
page 46 of Programming Erlang:
A function that returns a function-
Double =3D fun(X) -> ( 2 * X ) end.
When you call Double(X), it returns 2 * X.
A function that returns a generalization-
Mult =3D fun(Times) -> (fun(X) -> X * Times end) end.
This returns a function that calls X * Times.
Finally, a specific function that does what you want-
Triple =3D Mult(3).
This returns a function that calls X * 3.
When you invoke Triple(15), it returns 45.
Quad =3D Mult(4).
Quad(32) returns 128.
Half =3D Mult(0.5).
Half(100) returns 50.
etc.
CC
------------------------------
Date: Sun, 21 Jun 2009 14:14:33 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Reading perl substitute expressions from a file
Message-Id: <ae2cb940-c6e9-45c3-9da0-071817923db5@o21g2000prn.googlegroups.com>
On Jun 20, 5:33=A0am, Tad J McClellan <ta...@seesig.invalid> wrote:
> Luc Leemans <l.leem...@cox.net> wrote:
> > ...
>
> Sure.
>
> ...
> But I'm not a big fan of invisible side-effects like that.
>
> I'd prefer to make it clear that I'm changing the value of $val, so:
>
>...
> And change this line in the main program:
>
> =A0 =A0 $var =3D apply_substitutions($var);
>
<off-topic>
I'm not a Ruby enthusiast but I kinda like its bang
convention to denote a "destructive" method:
apply_substitutions!($var)
Of course, if Perl adopted it, the "Perl=3Dline noise" police would be
all over it :)
</off-topic>
--
Charles DeRykus
------------------------------
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 2487
***************************************