[31030] in Perl-Users-Digest
Perl-Users Digest, Issue: 2275 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 14 16:09:44 2009
Date: Sat, 14 Mar 2009 13:09:09 -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 Sat, 14 Mar 2009 Volume: 11 Number: 2275
Today's topics:
Re: Autovivification by foreach <hjp-usenet2@hjp.at>
Easy Multithread programing - Solution to Producers & C <howachen@gmail.com>
Re: Easy Multithread programing - Solution to Producers <smallpond@juno.com>
Re: FAQ posts <brian.d.foy@gmail.com>
Re: Most efficient way to do set-comparison <rvtol+usenet@xs4all.nl>
Re: Most efficient way to do set-comparison <rvtol+usenet@xs4all.nl>
new CPAN modules on Sat Mar 14 2009 (Randal Schwartz)
Re: Perl Pipes <tadmc@seesig.invalid>
Re: s/// parametrized with backreferences sln@netherlands.com
Re: s/// parametrized with backreferences <tadmc@seesig.invalid>
Re: s/// parametrized with backreferences sln@netherlands.com
Re: s/// parametrized with backreferences <tadmc@seesig.invalid>
Re: Wide character in subroutine entry - how to get byt <Alexander.Farber@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 14 Mar 2009 12:36:44 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Autovivification by foreach
Message-Id: <slrngrn5mc.sc9.hjp-usenet2@hrunkner.hjp.at>
On 2009-03-13 15:54, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "FS" == Frank Seitz <devnull4711@web.de> writes:
> >> into each element of its list. and $_ is read/write so the elements
> >> should be lvalues. so perl will autovivify the array ref since you might
> >> be modifying elements. it can't tell (the executed code could be a sub
> >> call, etc.) so it has to do this before the loop starts.
>
> FS> This explanation is not plausible to me. Perl autovivifies before
> FS> loop start, because the loop might be modifying array elements?
> FS> How is this possible? The autovivificated array is empty.
> FS> It is clear that the body of the loop is never executed.
>
> if perl didn't autovivify the lvalue in the for loop, then it would die
> if you attempted to modify an array ref element.
You can't attempt to do that since the loop body is never executed.
hp
------------------------------
Date: Sat, 14 Mar 2009 04:24:04 -0700 (PDT)
From: howa <howachen@gmail.com>
Subject: Easy Multithread programing - Solution to Producers & Consumers problem?
Message-Id: <4371ac0c-1646-4351-83e5-29891c89abc4@i20g2000prf.googlegroups.com>
Hello,
Are there any framework / modules/ library that will make writing
Multithread program, e.g. Producers & Consumers pattern (i.e
utilizing thread pool automatically) more easier?
Or any sample codes would be appreciated.
In term of Java, it is executor: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html
Thanks.
------------------------------
Date: Sat, 14 Mar 2009 06:28:59 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Easy Multithread programing - Solution to Producers & Consumers problem?
Message-Id: <4bc28b2a-145c-4db7-af36-cd1f237d6cbe@g38g2000yqd.googlegroups.com>
On Mar 14, 7:24=A0am, howa <howac...@gmail.com> wrote:
> Hello,
>
> Are there any framework / modules/ library that will make writing
> Multithread program, e.g. =A0Producers & Consumers pattern (i.e
> utilizing thread pool automatically) more easier?
>
> Or any sample codes would be appreciated.
>
> In term of Java, it is executor:http://java.sun.com/j2se/1.5.0/docs/api/j=
ava/util/concurrent/Executor...
>
> Thanks.
Maybe one of the Thread::Pool modules on CPAN would serve your need?
------------------------------
Date: Sat, 14 Mar 2009 02:35:23 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ posts
Message-Id: <140320090235236820%brian.d.foy@gmail.com>
In article <xdadnfJ_d-_cCSfUnZ2dnUVZ_jWWnZ2d@supernews.com>, darkon
<darkon.tdo@gmail.com> wrote:
> Out of simple curiousity, what algorithm is used to decide which FAQ is
> posted when? I noticed that the FAQs are posted roughly in sequence, but
> not strictly in sequence. For example, FAQs from section 5 began to be
> posted before all the FAQs from section 4 had been posted.
The script that does it all is in the perlfaq repository:
http://github.com/briandfoy/perlfaq/tree/master
Roughly, there's a script that splits up the faq into individual
questions, then the posting faq selects the one with the oldest mtime.
Some of the answers have the same mtime so it's slightly out of order.
It's not sophisticated, but it's also not important enough to put any
additional thought into it. :)
------------------------------
Date: Sat, 14 Mar 2009 13:24:05 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Most efficient way to do set-comparison
Message-Id: <49bba1e5$0$194$e4fe514c@news.xs4all.nl>
Gunnar Hjalmarsson wrote:
> $ perl -le '
> %legalopts = (a=>1, b=>1, c=>1); %opts = (a=>1, c=>1);
> @L = sort keys %legalopts; @O = sort keys %opts;
> print "@L" eq "@O" ? "Ok" : "Not equal"
> '
> Not equal
I hate suggestions like that, because the stringifications of the arrays
can be equal when the arrays aren't.
--
Ruud
------------------------------
Date: Sat, 14 Mar 2009 14:44:11 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Most efficient way to do set-comparison
Message-Id: <49bbb4ac$0$183$e4fe514c@news.xs4all.nl>
Krishna Chaitanya wrote:
> If set A defined elements a,b,c (a set of permissible program options,
> let's say), and we receive from user options in set B.
>
> I want to make sure that user options in B are exactly same as those
> defined in A .... nothing more, nothing less and completely
> identical....this represents some kinda set operation if I'm not
> wrong...
>
> A U B = A
> A int B = A
>
> How to do this most efficiently in Perl...?
See List:Util and List::MoreUtils.
Or call this:
sub cmp_set {
my %a; @a{ @{$_[0]} } = (); delete @a{ @{$_[1]} };
my %b; @b{ @{$_[1]} } = (); delete @b{ @{$_[0]} };
if ( %b ) {
return 2 if %a; # dissimilar
return -1;
}
return %a ? 1 : 0;
}
--
Ruud
------------------------------
Date: Sat, 14 Mar 2009 04:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Mar 14 2009
Message-Id: <KGHBqq.Hxq@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.
Acme-Tie-Formatted-0.03
http://search.cpan.org/~mcmahon/Acme-Tie-Formatted-0.03/
embed sprintf() formatting in regular print()
----
Attribute-Handlers-0.83
http://search.cpan.org/~smueller/Attribute-Handlers-0.83/
Simpler definition of attribute handlers
----
Bot-BasicBot-Pluggable-Module-Log-0.05
http://search.cpan.org/~mdom/Bot-BasicBot-Pluggable-Module-Log-0.05/
Provide logging for Bot::BasicBot::Pluggable
----
CGI-Application-Plugin-GenVal-0.01_02
http://search.cpan.org/~cosmicnet/CGI-Application-Plugin-GenVal-0.01_02/
Generate input forms with client/server validation
----
CGI-Simple-1.108
http://search.cpan.org/~andya/CGI-Simple-1.108/
A Simple totally OO CGI interface that is CGI.pm compliant
----
Chart-Gnuplot-0.09
http://search.cpan.org/~kwmak/Chart-Gnuplot-0.09/
Plot graph using Gnuplot on the fly
----
DBD-ODBC-1.18_3
http://search.cpan.org/~mjevans/DBD-ODBC-1.18_3/
ODBC Driver for DBI
----
DBD-ODBC-1.18_4
http://search.cpan.org/~mjevans/DBD-ODBC-1.18_4/
ODBC Driver for DBI
----
Data-Rx-TypeBundle-Perl-0.003
http://search.cpan.org/~rjbs/Data-Rx-TypeBundle-Perl-0.003/
experimental / perl types
----
Email-Sender-0.003
http://search.cpan.org/~rjbs/Email-Sender-0.003/
a library for sending email
----
File-Wildcard-0.11
http://search.cpan.org/~ivorw/File-Wildcard-0.11/
Enhanced glob processing
----
Git-PurePerl-0.39
http://search.cpan.org/~lbrocard/Git-PurePerl-0.39/
A Pure Perl interface to Git repositories
----
Git-PurePerl-0.40
http://search.cpan.org/~lbrocard/Git-PurePerl-0.40/
A Pure Perl interface to Git repositories
----
Gtk2-Ex-WidgetCursor-8
http://search.cpan.org/~kryde/Gtk2-Ex-WidgetCursor-8/
mouse pointer cursor management for widgets
----
Guardian-OpenPlatform-API-0.05
http://search.cpan.org/~davecross/Guardian-OpenPlatform-API-0.05/
Access the Guardian OpenPlatform API
----
HTML-WikiConverter-Markdown-0.04
http://search.cpan.org/~diberri/HTML-WikiConverter-Markdown-0.04/
Convert HTML to Markdown markup
----
HTTP-Engine-0.1.4_04
http://search.cpan.org/~yappo/HTTP-Engine-0.1.4_04/
Web Server Gateway Interface and HTTP Server Engine Drivers (Yet Another Catalyst::Engine)
----
Hash-FieldHash-0.05
http://search.cpan.org/~gfuji/Hash-FieldHash-0.05/
A lightweight field hash implementation
----
LCFG-Build-PkgSpec-0.0.29
http://search.cpan.org/~sjquinney/LCFG-Build-PkgSpec-0.0.29/
Object-oriented interface to LCFG build metadata
----
LCFG-Build-Skeleton-0.0.12
http://search.cpan.org/~sjquinney/LCFG-Build-Skeleton-0.0.12/
LCFG software package generator
----
LCFG-Build-Tools-0.0.55
http://search.cpan.org/~sjquinney/LCFG-Build-Tools-0.0.55/
LCFG software release tools
----
LCFG-Build-VCS-0.0.30
http://search.cpan.org/~sjquinney/LCFG-Build-VCS-0.0.30/
LCFG version-control infrastructure
----
List-Conditional-0.01
http://search.cpan.org/~obradovic/List-Conditional-0.01/
Create lists based on a condition for each element
----
List-Flatten-0.01
http://search.cpan.org/~obradovic/List-Flatten-0.01/
Interpolate array references in a list
----
Math-Disarrange-List-1.002
http://search.cpan.org/~prbrenan/Math-Disarrange-List-1.002/
Generate all disarrangements of a list.
----
Math-Permute-List-1.002
http://search.cpan.org/~prbrenan/Math-Permute-List-1.002/
Generate all permutations of a list.
----
Math-Subsets-List-1.002
http://search.cpan.org/~prbrenan/Math-Subsets-List-1.002/
----
Method-Destructor-0.01
http://search.cpan.org/~gfuji/Method-Destructor-0.01/
Cumulative destructors
----
MouseX-AttributeHelpers-0.03
http://search.cpan.org/~masaki/MouseX-AttributeHelpers-0.03/
Extend your attribute interfaces
----
Object-LocalVars-0.18
http://search.cpan.org/~dagolden/Object-LocalVars-0.18/
Outside-in objects with local aliasing of $self and object variables
----
POE-XS-Queue-Array-0.005_01
http://search.cpan.org/~tonyc/POE-XS-Queue-Array-0.005_01/
an XS implementation of POE::Queue::Array.
----
Padre-0.29
http://search.cpan.org/~szabgab/Padre-0.29/
Perl Application Development and Refactoring Environment
----
Padre-Plugin-Autoformat-0.1.0
http://search.cpan.org/~jquelin/Padre-Plugin-Autoformat-0.1.0/
reformat your text within Padre
----
Padre-Plugin-Autoformat-0.2.0
http://search.cpan.org/~jquelin/Padre-Plugin-Autoformat-0.2.0/
reformat your text within Padre
----
Padre-Plugin-Autoformat-0.2.1
http://search.cpan.org/~jquelin/Padre-Plugin-Autoformat-0.2.1/
reformat your text within Padre
----
Padre-Plugin-Git-0.01
http://search.cpan.org/~kaare/Padre-Plugin-Git-0.01/
Simple Git interface for Padre
----
Parse-Dia-SQL-0.04
http://search.cpan.org/~aff/Parse-Dia-SQL-0.04/
Convert Dia class diagrams into SQL.
----
Parse-RPN-2.44
http://search.cpan.org/~fdulau/Parse-RPN-2.44/
----
RDF-Query-2.003_03
http://search.cpan.org/~gwilliams/RDF-Query-2.003_03/
An RDF query implementation of SPARQL/RDQL in Perl for use with RDF::Redland and RDF::Core.
----
RTx-Calendar-0.07
http://search.cpan.org/~nchuche/RTx-Calendar-0.07/
Calendar for RT due tasks
----
RTx-EmailCompletion-0.06
http://search.cpan.org/~nchuche/RTx-EmailCompletion-0.06/
Add auto completion on RT email fields
----
SVN-Hooks-0.15.41
http://search.cpan.org/~gnustavo/SVN-Hooks-0.15.41/
A framework for implementing Subversion hooks.
----
Simo-0.1005
http://search.cpan.org/~kimoto/Simo-0.1005/
Very simple framework for Object Oriented Perl.
----
Sys-Info-Base-0.69_03
http://search.cpan.org/~burak/Sys-Info-Base-0.69_03/
Base class for Sys::Info
----
Sys-Info-Driver-Unknown-0.69_02
http://search.cpan.org/~burak/Sys-Info-Driver-Unknown-0.69_02/
Compatibility layer for Sys::Info
----
Sys-Info-Driver-Windows-0.69_04
http://search.cpan.org/~burak/Sys-Info-Driver-Windows-0.69_04/
Windows driver for Sys::Info
----
Task-Padre-Plugin-Deps-0.10
http://search.cpan.org/~fayland/Task-Padre-Plugin-Deps-0.10/
prereqs of Padre::Plugins
----
Task-Padre-Plugins-0.17
http://search.cpan.org/~fayland/Task-Padre-Plugins-0.17/
Get many Plugins of Padre at once
----
Test-DistManifest-1.1.1
http://search.cpan.org/~frequency/Test-DistManifest-1.1.1/
Tests that your MANIFEST matches the distribution as it exists, excluding those in your MANIFEST.SKIP
----
Text-CSV_XS-0.62
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.62/
comma-separated values manipulation routines
----
Text-Capitalize-0.7
http://search.cpan.org/~doom/Text-Capitalize-0.7/
capitalize strings ("to WORK AS titles" becomes "To Work as Titles")
----
Text-xSV-0.17
http://search.cpan.org/~tilly/Text-xSV-0.17/
read character separated files
----
WWW-Scraper-ISBN-ISBNdb_Driver-0.07
http://search.cpan.org/~diberri/WWW-Scraper-ISBN-ISBNdb_Driver-0.07/
isbndb.com driver for WWW::Scraper::ISBN
----
WebService-Nestoria-Search-1.14.7
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-1.14.7/
Perl interface to the Nestoria Search public API.
----
XML-RSS-FromHTML-0.04
http://search.cpan.org/~bashi/XML-RSS-FromHTML-0.04/
simple framework for making RSS out of HTML
----
libapreq2-2.12
http://search.cpan.org/~joesuf/libapreq2-2.12/
----
random-0.01
http://search.cpan.org/~jmeltzer/random-0.01/
have rand() return integers
----
random-0.02
http://search.cpan.org/~jmeltzer/random-0.02/
have rand() return integers or fixed values
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: Fri, 13 Mar 2009 21:36:56 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Perl Pipes
Message-Id: <slrngrm628.c6k.tadmc@tadmc30.sbcglobal.net>
alertjean@rediffmail.com <alertjean@rediffmail.com> wrote:
> On Mar 12, 7:01 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>> alertj...@rediffmail.com <alertj...@rediffmail.com> wrote:
>> > Fellow script writers,
>> > I have two linux executables. I want to give the stand ouput of
>> > executable1 to executable 2.
>> > How can I do it with perl without creating intermediate files ?
>>
>> > something which can be achieved through command line.
>>
>> > $ executable1 > output_file1.txt
>> > $ executable2 output_file1.txt > output_file2.txt
>>
>> The simplest way is to let the shell do it for you:
>>
>> system 'executable1 | executable2 >output_file2.txt';
>>
>> Or, if you want to capture the end of the pipeline into your Perl
>> program rather than into a file:
>>
>> open my $pipeline, 'executable1 | executable2 |' or die...
>>
>> Then you can read the data with:
>>
>> while ( <$pipeline> ) {
>> ...
>>
>> --
>> Tad McClellan
>> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
>
>
> This is what I do currently
>
> system("./CacheSimulator.exe $setsL1 $blockSize $assocL1 $pref_nL1
> $pref_mL1 $TraceFile L1_Summary.txt > L1_Traffic_Out.txt");
>
> system("./CacheSimulator.exe $setsL2 $blockSize $assocL2 $pref_nL2
> $pref_mL2 L1_Traffic_Out.txt L2_Summary.txt > L2_Traffic_Out.txt");
>
>
> I want to give L1_Traffic_Out.txt to the second execution
>
> Can I achieve this by the methods you have mentioned ?
What happened when you tried it?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 14 Mar 2009 01:57:52 GMT
From: sln@netherlands.com
Subject: Re: s/// parametrized with backreferences
Message-Id: <bp2mr4tjqb5uqs1kc62vmdkp87vv0ndma0@4ax.com>
On Fri, 13 Mar 2009 17:42:34 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>sln@netherlands.com <sln@netherlands.com> wrote:
>> On Wed, 11 Mar 2009 16:24:17 -0700 (PDT), msciwoj <m@epf.pl> wrote:
>
>>>The mystery for me is this 'second' evaluation actually, like you
>>>said, "interpolates the values for $2 and $1 into the replacement
>>>string" and it seems it's the only way that does the job.
>>>A bit of mystery for me but at the end it works and only this counts,
>>>I guess.
>
>
>> In the nut of it, evaling a variable with a value '$str'
>> will work,
>
>
>Because the value is a valid Perl expression.
>
>
>> but with a value of '$str\n$str' will not.
>
>
>Because the value is not a valid Perl expression.
>
>
>> But if you notice, the vaule of '$str\n$str' and '$str\\n$str'
>> are equal.
>
>
>That is how single quoted strings work.
>
>The "Scalar value constructors" section in perldata points out that
>there are only 2 special characters in a single quoted string.
>
>Single quote is special (it marks the end of the string) unless
>it is preceded by a backslash.
>
>Backslash is special if it preceeds a single quote or a backslash.
>
>A backslash that does not preceed 1 of those 2 characters is literal.
>
>So the 1st string above has a literal backslash and an "n" in it.
>
>The 2nd string above has a backslashed backslash (which becomes
>a backslash) and an "n" in it.
>
>
>> In escence, there is a conflict with the parser on some
>> level that is not quite understood
>
>
>Don't let that stop you from pretending to answer questions about it.
>
>
>> as pertaining to eval.
>
>
>It has nothing to do with eval.
>
>It has to do with single-quoted strings.
>
>
>> Whitness the below code. All works fine. Replace "replacement2" variable
>> with this value: '$2\n' and watch the error's.
>
>
>That is because in the code below, the value of $replacement2
>is a valid expression:
>
> perl -e '$2'
>
>But the value you suggest above is not a valid expression:
>
> perl -e '$2\n'
>
Oh, I get it. Its all about "valid expression" now and not eval in regex's.
And now since you have stated '$2' is a valid expression and '$2\n' isn't,
it raises the question of the ilogic in your nothing, so nothing argument.
Now, given the "valid expression" of '$2', this should be equivalent in terms of eval:
$replacement2 = '$2';
$data =~ /(.)\n(.)/;
$e = eval ($replacement2);
print "->",$e,"\n";
$data =~ s/(.)\n(.)/$replacement2/eg;
print $data."\n";
Unfortunately, you forgot your brain today Tad.
-sln
------------------------------
Date: Fri, 13 Mar 2009 21:48:55 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: s/// parametrized with backreferences
Message-Id: <slrngrm6on.c6k.tadmc@tadmc30.sbcglobal.net>
sln@netherlands.com <sln@netherlands.com> wrote:
> On Fri, 13 Mar 2009 17:42:34 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>
>>> In the nut of it, evaling a variable with a value '$str'
>>> will work,
>>
>>
>>Because the value is a valid Perl expression.
>>
>>
>>> but with a value of '$str\n$str' will not.
>>
>>
>>Because the value is not a valid Perl expression.
> Oh, I get it. Its all about "valid expression"
You're welcome.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 14 Mar 2009 14:32:20 GMT
From: sln@netherlands.com
Subject: Re: s/// parametrized with backreferences
Message-Id: <tqfnr4hrl0em73226ljtnfqbqhb2doo9s9@4ax.com>
On Fri, 13 Mar 2009 21:48:55 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>sln@netherlands.com <sln@netherlands.com> wrote:
>> On Fri, 13 Mar 2009 17:42:34 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>>
>
>>>> In the nut of it, evaling a variable with a value '$str'
>>>> will work,
>>>
>>>
>>>Because the value is a valid Perl expression.
>>>
>>>
>>>> but with a value of '$str\n$str' will not.
>>>
>>>
>>>Because the value is not a valid Perl expression.
>
>
>> Oh, I get it. Its all about "valid expression"
>
>
>You're welcome.
No thanks! But you are welcome.
Here's some valid expression for ya Tad:
$replacement2 = '$2';
$data =~ /(.)\n(.)/;
$e = eval ($replacement2);
print "->",$e,"\n";
$data =~ s/(.)\n(.)/$replacement2/eg;
print $data."\n";
------------------------------
Date: Sat, 14 Mar 2009 11:14:37 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: s/// parametrized with backreferences
Message-Id: <slrngrnlvd.ifm.tadmc@tadmc30.sbcglobal.net>
sln@netherlands.com <sln@netherlands.com> wrote:
> On Fri, 13 Mar 2009 21:48:55 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>
>>sln@netherlands.com <sln@netherlands.com> wrote:
>>> On Fri, 13 Mar 2009 17:42:34 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:
>>>
>>
>>>>> In the nut of it, evaling a variable with a value '$str'
>>>>> will work,
>>>>
>>>>
>>>>Because the value is a valid Perl expression.
>>>>
>>>>
>>>>> but with a value of '$str\n$str' will not.
>>>>
>>>>
>>>>Because the value is not a valid Perl expression.
>>
>>
>>> Oh, I get it. Its all about "valid expression"
>>
>>
>>You're welcome.
>
> No thanks! But you are welcome.
>
> Here's some valid expression for ya Tad:
>
> $replacement2 = '$2';
> $data =~ /(.)\n(.)/;
> $e = eval ($replacement2);
> print "->",$e,"\n";
>
> $data =~ s/(.)\n(.)/$replacement2/eg;
> print $data."\n";
That works as expected. Since there is only one eval with s///e,
the result after evaluating $replacement2 is the string '$2'.
What were you expecting it to do instead?
If you were expecting the last print to print the value of the $2
variable, then you don't have enough levels of eval to get to where
'$2' is evaluated.
The 2nd level of eval can be gotten with either
$data =~ s/(.)\n(.)/$replacement2/eeg;
or
$data =~ s/(.)\n(.)/$e/eg;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 14 Mar 2009 03:40:57 -0700 (PDT)
From: "A. Farber" <Alexander.Farber@gmail.com>
Subject: Re: Wide character in subroutine entry - how to get bytes for md5_hex?
Message-Id: <11159846-38f6-4e68-8cb6-2a862b4f1f84@13g2000yql.googlegroups.com>
Sorry should have RTFM last night:
print md5_hex(encode_utf8($str)), "\n";
------------------------------
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 2275
***************************************