[31190] in Perl-Users-Digest
Perl-Users Digest, Issue: 2435 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 22 16:14:22 2009
Date: Fri, 22 May 2009 13:14:14 -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 Fri, 22 May 2009 Volume: 11 Number: 2435
Today's topics:
double variable interpolation question <cartercc@gmail.com>
Re: double variable interpolation question <RedGrittyBrick@spamweary.invalid>
Re: double variable interpolation question <jimsgibson@gmail.com>
Re: double variable interpolation question <uri@StemSystems.com>
Re: double variable interpolation question <cartercc@gmail.com>
Re: double variable interpolation question <jimsgibson@gmail.com>
Re: double variable interpolation question <uri@StemSystems.com>
Re: double variable interpolation question <ben@morrow.me.uk>
Re: double variable interpolation question <uri@StemSystems.com>
Re: EasyNews and this Perl group <vinnie_baddabing@yahoo.com>
Re: EasyNews and this Perl group <nat.k@gm.ml>
Re: edit array in place <brandon@geronimoa11oys.invalid>
Re: edit array in place <uri@StemSystems.com>
Re: edit array in place <ben@morrow.me.uk>
Re: edit array in place <uri@StemSystems.com>
Re: Is PERL good for a linguist new to programming? <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 May 2009 09:14:43 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: double variable interpolation question
Message-Id: <2ea8e7fe-21fd-4fc2-af48-a4f1c08ea71a@h11g2000yqb.googlegroups.com>
I've been asked to maintain a web application/site which runs on
Linux, Postgres, Apache, and Perl.
The script contains these lines which query a database:
my $page = param('page');
my $person = param('person');
my $doc_ref = get_doc_ref($page);
my $per_ref = get_per_ref($person);
When I print the values, this is what I get:
print $doc_ref->[0] returns
<body>
<h1>Hello, #a_name#</h1>
<p>You have won #a_prize#.</p>
</body>
print $per_ref->{a_name) returns 'John Smith'
print $per_ref->{a_prize} returns 'dinner at Outback Steakhouse'
The next line assigns the $doc_ref to a scalar:
my $doc = $doc_ref->[0];
My question relates to the IN BETWEEN code here, which I'll come back
to.
After the IN BETWEEN code executes, we have this:
print $doc;
This results in the the following:
<body>
<h1>Hello, John Smith</h1>
<p>You have won dinner at Outback Steakhouse.</p>
</body>
Here is the IN BETWEEN code:
$doc =~ s/#a_name#/$per_ref->{a_name}/g;
$doc =~ s/#a_prize#/$per_ref->{a_prize}/g;
... and so on for a large number of variables. There are many pages,
and some of the pages contain thousands of different values.
I have tried several different ways to fold the $per_ref data into the
$doc without the IN BETWEEN code, all without success. My question is
whether this is even possible? Do I have to accept the IN BETWEEN
substitutions, or can I directly update one scalar variable ($doc)
with a number of other scalars?
The good news is that the old code works perfectly. The bad news is
that I'm staring at a lot of mindless coding. If I could change the
database and have everything automatically update, I'd be very happy.
Thanks, CC.
------------------------------
Date: Fri, 22 May 2009 17:37:39 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: double variable interpolation question
Message-Id: <4a16d4d4$0$24011$db0fefd9@news.zen.co.uk>
ccc31807 wrote:
> I've been asked to maintain a web application/site which runs on
> Linux, Postgres, Apache, and Perl.
>
> The script contains these lines which query a database:
> my $page = param('page');
> my $person = param('person');
> my $doc_ref = get_doc_ref($page);
> my $per_ref = get_per_ref($person);
>
> When I print the values, this is what I get:
> print $doc_ref->[0] returns
> <body>
> <h1>Hello, #a_name#</h1>
> <p>You have won #a_prize#.</p>
> </body>
> print $per_ref->{a_name) returns 'John Smith'
> print $per_ref->{a_prize} returns 'dinner at Outback Steakhouse'
>
> The next line assigns the $doc_ref to a scalar:
> my $doc = $doc_ref->[0];
>
...
> $doc =~ s/#a_name#/$per_ref->{a_name}/g;
> $doc =~ s/#a_prize#/$per_ref->{a_prize}/g;
> ... and so on for a large number of variables. There are many pages,
> and some of the pages contain thousands of different values.
Hmm, can't you loop over the keys of the hash pointed at by $per_ref and
for each key substitute /#$key#/$value/;
perl -e '%x=qw(name fred age 23); \
$y="foo #name# bar #age# end"; \
for(keys %x) {$y=~s/#$_#/$x{$_}/g;} \
print "$y\n";
foo fred bar 23 end
Someone will be along soon with a FAQ ref and a much better solution.
--
RGB
------------------------------
Date: Fri, 22 May 2009 09:39:10 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: double variable interpolation question
Message-Id: <220520090939104568%jimsgibson@gmail.com>
In article
<2ea8e7fe-21fd-4fc2-af48-a4f1c08ea71a@h11g2000yqb.googlegroups.com>,
ccc31807 <cartercc@gmail.com> wrote:
> I've been asked to maintain a web application/site which runs on
> Linux, Postgres, Apache, and Perl.
>
> The script contains these lines which query a database:
> my $page = param('page');
> my $person = param('person');
> my $doc_ref = get_doc_ref($page);
> my $per_ref = get_per_ref($person);
>
> When I print the values, this is what I get:
> print $doc_ref->[0] returns
> <body>
> <h1>Hello, #a_name#</h1>
> <p>You have won #a_prize#.</p>
> </body>
> print $per_ref->{a_name) returns 'John Smith'
> print $per_ref->{a_prize} returns 'dinner at Outback Steakhouse'
>
> The next line assigns the $doc_ref to a scalar:
> my $doc = $doc_ref->[0];
>
> My question relates to the IN BETWEEN code here, which I'll come back
> to.
>
> After the IN BETWEEN code executes, we have this:
> print $doc;
>
> This results in the the following:
> <body>
> <h1>Hello, John Smith</h1>
> <p>You have won dinner at Outback Steakhouse.</p>
> </body>
>
> Here is the IN BETWEEN code:
> $doc =~ s/#a_name#/$per_ref->{a_name}/g;
> $doc =~ s/#a_prize#/$per_ref->{a_prize}/g;
> ... and so on for a large number of variables. There are many pages,
> and some of the pages contain thousands of different values.
To me, that looks like a home-grown "templating" system, where the
programmer has identified a field such as '#a_name#' and is using the
substitution operator to fill in the variable with their actual values
at runtime based on the form input and subsequent database query.
>
> I have tried several different ways to fold the $per_ref data into the
> $doc without the IN BETWEEN code, all without success. My question is
> whether this is even possible? Do I have to accept the IN BETWEEN
> substitutions, or can I directly update one scalar variable ($doc)
> with a number of other scalars?
The substitute operator would seem to be the best choice for updating a
scalar by substituting values for embedded variables.
> The good news is that the old code works perfectly. The bad news is
> that I'm staring at a lot of mindless coding. If I could change the
> database and have everything automatically update, I'd be very happy.
It doesn't look like mindless coding to me. That said, if I were going
to implement this from scratch, I would consider using one of the
existing templating systems available from CPAN. There are several.
However, if your program is working, and working well, why change it?
Maybe you just need to spend more time learning about how it works.
The advantage of the templating systems is that they usually have more
powerful semantics than simple substitution, and can be extended more
easily. If you are thinking about adding more functionality to your
program, then you might want to consider re-implementing using a
templating system.
--
Jim Gibson
------------------------------
Date: Fri, 22 May 2009 13:03:53 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: double variable interpolation question
Message-Id: <87iqjtdq86.fsf@quad.sysarch.com>
>>>>> "c" == ccc31807 <cartercc@gmail.com> writes:
c> Here is the IN BETWEEN code:
c> $doc =~ s/#a_name#/$per_ref->{a_name}/g;
c> $doc =~ s/#a_prize#/$per_ref->{a_prize}/g;
c> ... and so on for a large number of variables. There are many pages,
c> and some of the pages contain thousands of different values.
that is a basic templating thing. and if the #foo# name is ALWAYS the
same (or easily derived) as the hash key name, you can reduce all of
those to one simple s/// operation:
s/#(\w+?)#/$per_ref->{$1}/g ;
if you need to do more work on $1 to convert the name, then add the /e
modifier so you can put code in the replacement part.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 22 May 2009 11:11:22 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: double variable interpolation question
Message-Id: <00409a74-ee7f-4176-b6ee-861ad89af250@f19g2000yqh.googlegroups.com>
On May 22, 1:03=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> =A0 =A0 =A0 =A0 s/#(\w+?)#/$per_ref->{$1}/g ;
This works perfectly. I wasn't looking for this kind of solution, but
it works perfectly, and I have now modified the first script and
commented out 27 lines that are now surplus.
A question and a comment.
Question: Is there any reason you didn't use something like this?
s/#[^#]*#/$per_ref->{$1}/g ;
From what little I understand about the way RE's work, the non-greedy
quantifier has to first match to the end, while the any-character-but
stops matching when it reaches the character it is looking for.
Comment: Yes, I suppose this is a home grown templating system.
However, instead of days of work I'm now looking at hours, and I don't
really have an incentive to rewrite the entire application. There is a
book on Catalyst that I've been thinking about buying. Would it be
worth my time to buy it and read it? I work on web enabled apps fairly
often.
Thanks, CC.
------------------------------
Date: Fri, 22 May 2009 11:23:19 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: double variable interpolation question
Message-Id: <220520091123197139%jimsgibson@gmail.com>
In article
<00409a74-ee7f-4176-b6ee-861ad89af250@f19g2000yqh.googlegroups.com>,
ccc31807 <cartercc@gmail.com> wrote:
> On May 22, 1:03 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> > s/#(\w+?)#/$per_ref->{$1}/g ;
>
> This works perfectly. I wasn't looking for this kind of solution, but
> it works perfectly, and I have now modified the first script and
> commented out 27 lines that are now surplus.
>
> A question and a comment.
> Question: Is there any reason you didn't use something like this?
> s/#[^#]*#/$per_ref->{$1}/g ;
> From what little I understand about the way RE's work, the non-greedy
> quantifier has to first match to the end, while the any-character-but
> stops matching when it reaches the character it is looking for.
Non-greedy matches do not have to first match to the end. They should
stop when the first match is encountered. Just how they do that is
known only to those familiar with Perl's Regular Expression Engine,
i.e., not me.
Your templating system uses '#' to denote the variables. Either of
those REs will work, provided you do not have any other '#' characters
in your source text. The difference is when there are other '#'
characters in the text. Your RE will match '# this is a comment #'
while Uri's will not. They will both match '#comment#'.
--
Jim Gibson
------------------------------
Date: Fri, 22 May 2009 14:29:26 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: double variable interpolation question
Message-Id: <874ovdc7p5.fsf@quad.sysarch.com>
>>>>> "c" == ccc31807 <cartercc@gmail.com> writes:
c> On May 22, 1:03 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
>> s/#(\w+?)#/$per_ref->{$1}/g ;
c> This works perfectly. I wasn't looking for this kind of solution, but
c> it works perfectly, and I have now modified the first script and
c> commented out 27 lines that are now surplus.
of course it works perfectly. it is the classic single level (scalar
values only) templater in one line. i used that many times for many
years on various projects. i have seen your existing style too often. a
client's code base had about 100 s/// ops doing the same thing ON EACH
LINE OF A LOOP!! talk about inefficient. but soon you will need more
power and you should check out Template::Simple as it does the scalar
and more with very easy to use markup and it is faster than all the
others too.
c> A question and a comment.
c> Question: Is there any reason you didn't use something like this?
c> s/#[^#]*#/$per_ref->{$1}/g ;
c> From what little I understand about the way RE's work, the non-greedy
c> quantifier has to first match to the end, while the any-character-but
c> stops matching when it reaches the character it is looking for.
that works too. no reason i used that other than habit. also if the
delimiter isn't one char (common ones are [% and %], then you can't use
the negated char class. also yours doesn't work well with dealing with
escaped closing delimiters.
c> Comment: Yes, I suppose this is a home grown templating system.
c> However, instead of days of work I'm now looking at hours, and I don't
c> really have an incentive to rewrite the entire application. There is a
c> book on Catalyst that I've been thinking about buying. Would it be
c> worth my time to buy it and read it? I work on web enabled apps fairly
c> often.
catalyst isn't a templating system but a full web app engine system. the
large template systems are mason and template toolkit. there are other
smaller ones like html::template. of course mine is smaller, simpler,
faster and better. :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 22 May 2009 19:47:59 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: double variable interpolation question
Message-Id: <vj8je6-8r4.ln1@osiris.mauzo.dyndns.org>
Quoth ccc31807 <cartercc@gmail.com>:
> On May 22, 1:03 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> > s/#(\w+?)#/$per_ref->{$1}/g ;
>
> This works perfectly. I wasn't looking for this kind of solution, but
> it works perfectly, and I have now modified the first script and
> commented out 27 lines that are now surplus.
>
> A question and a comment.
> Question: Is there any reason you didn't use something like this?
> s/#[^#]*#/$per_ref->{$1}/g ;
> From what little I understand about the way RE's work, the non-greedy
> quantifier has to first match to the end, while the any-character-but
> stops matching when it reaches the character it is looking for.
The answer to this sort of question can be found using -Mre=debug,
though interpreting the output can be a little tricky. In this case, the
interesting parts are:
~% perl -Mre=debug -e'"foo #bar# baz #quux#" =~ /#.*?#/'
<snip>
Matching REx "#.*?#" against "#bar# baz #quux# "
4 <foo > <#bar# baz > | 1:EXACT <#>(3)
5 <foo #> <bar# baz #> | 3:MINMOD(4)
5 <foo #> <bar# baz #> | 4:STAR(6)
REG_ANY can match 3 times out of 3...
8 < #bar> <# baz #quu> | 6: EXACT <#>(8)
9 <#bar#> < baz #quux> | 8: END(0)
Match successful!
<snip>
~% perl -Mre=debug -e'"foo #bar# baz #quux#" =~ /#[^#]*#/'
<snip>
Matching REx "#[^#]*#" against "#bar# baz #quux# "
4 <foo > <#bar# baz > | 1:EXACT <#>(3)
5 <foo #> <bar# baz #> | 3:STAR(15)
ANYOF[\0-"$-\377{unicode_all}]
can match 3 times out of 2147483647...
8 < #bar> <# baz #quu> | 15: EXACT <#>(17)
9 <#bar#> < baz #quux> | 17: END(0)
Match successful!
so the two consider exactly the same set of possible matches before
succeeding.
> Comment: Yes, I suppose this is a home grown templating system.
> However, instead of days of work I'm now looking at hours, and I don't
> really have an incentive to rewrite the entire application.
~% cat ts
#!/usr/bin/perl
use 5.010;
use Template::Simple;
my $str = "foo #bar# baz #quux#";
my %data = ( bar => "ONE", quux => "TWO" );
my $out = Template::Simple
->new(pre_delim => qr/#/, post_delim => qr/#/)
->render(\$str, \%data);
say $$out;
~% perl ts
foo ONE baz TWO
~%
No need to rewrite anything :).
> There is a book on Catalyst that I've been thinking about buying.
> Would it be worth my time to buy it and read it? I work on web enabled
> apps fairly often.
I like Catalyst, but is very much a framework: you have to write at
least the core of your app as a Catalyst application. It is good about
allowing you to use modules that weren't developed for Catalyst as e.g.
data sources, though, so you would probably be able to keep large parts
of the code you've already written. It requires a familiarity with OO
Perl: in particular, Catalyst is now moving towards being entirely
Moose-based, so you would have to get comfortable with that.
Ben
------------------------------
Date: Fri, 22 May 2009 15:12:30 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: double variable interpolation question
Message-Id: <87vdntar4x.fsf@quad.sysarch.com>
>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
>> Comment: Yes, I suppose this is a home grown templating system.
>> However, instead of days of work I'm now looking at hours, and I don't
>> really have an incentive to rewrite the entire application.
BM> ~% cat ts
BM> #!/usr/bin/perl
BM> use 5.010;
BM> use Template::Simple;
BM> my $str = "foo #bar# baz #quux#";
BM> my %data = ( bar => "ONE", quux => "TWO" );
BM> my $out = Template::Simple
-> new(pre_delim => qr/#/, post_delim => qr/#/)
-> render(\$str, \%data);
i tend to not daisy chain that but it works. also if you want to apply
the template object more than once you need to keep it.
BM> say $$out;
BM> ~% perl ts
BM> foo ONE baz TWO
BM> ~%
BM> No need to rewrite anything :).
nice plug!! :)
and i have added a compiled template option which works but isn't
released yet. it needs some tests and docs (not much but too low on my
list). if you want that, you can get it from the git repo at:
perlhunter.com/git
and you can browse it at:
perlhunter.com/git/gitweb/gitweb.cgi
the api is trivial, just compile a template (by name) first and then
render as normal. it is much faster than the current rendering and blows
away anything else out there. but of course comparing this to mason and
template toolkit is not fair to them! :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: 22 May 2009 10:34:47 -0700
From: Vincent <vinnie_baddabing@yahoo.com>
Subject: Re: EasyNews and this Perl group
Message-Id: <gv6nnn0fll@drn.newsguy.com>
I had problems with Easynews since January. The original guys that started the
company have left, and the people currently running the service don't know what
the hell they are doing. Posts should take a few minutes at the most to show up
your local / originating news server NOT 30 minutes.
I switched over to Newsguy.com a few months ago, and have been very happy with
their service. I get 60GB of download capacity (Easynews 30GB) and I'm paying $9
month on their annual plan (Easynews $15 month).
With Newsguy I get NNTP & Web access, search engine, SSL encryption, and my
unused GB's rollover each month. They have a free trial, and may be worth a
look.
Vince
In article <fp2sv4tbmb9bthvjs4t1pabf3f1p2n4pkl@4ax.com>, sln@netherlands.com
says...
>
>Lets see if this one gets through.
>-sln
>
>----------------------------------------------------
>So let me get this straight.
>
>I originate a post to/on EasyNews servers, it gets posted to Usenet but doesen't
>hit your YOUR server for 30 minutes?
>
>Thats not even possible. This is a some other problem.
>
>I'm very unhappy with your service. I am looking into a different provider.
>
>----- Original Message -----
>From: Support via RT
>To:
>Sent: Sunday, May 03, 2009 1:57 PM
>Subject: [Ticket #825385] '[Sorry. This message is no longer available.]'
>
>
>Hello,
>
>Posts normally take in the order of 30 minutes to appear on our servers,
>though they do make it out to Usenet sooner than this. We have plans to
>implement a posting-oriented server for people who value speed, but at
>the moment, posts simply take a bit to appear. Please let us know if you
>have any questions or concerns.
>
>
>Easynews Support Team
>
>
------------------------------
Date: Fri, 22 May 2009 12:51:07 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: EasyNews and this Perl group
Message-Id: <LmDRl.132373$ew.37649@newsfe24.iad>
Vincent wrote:
> I had problems with Easynews since January.
Ignore that poster, he's a troll.
------------------------------
Date: Fri, 22 May 2009 08:17:03 -0500
From: Brandon Metcalf <brandon@geronimoa11oys.invalid>
Subject: Re: edit array in place
Message-Id: <slrnh1d7ee.6il.brandon@cedar.geronimoalloys.com>
On 2009-05-21, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "BM" == Brandon Metcalf <brandon@geronimoalloys.invalid> writes:
>
> BM> It seems there should be a better way of accomplishing what the
> BM> following does, but I'm not coming up with anything.
>
> BM> @f = map($_ =~ s/"0000-00-00"/NULL/ ? $_ : $_, @f);
>
> why are you using ?: there when you return $_ whether it was changed or not??
> the normal way to use map and s/// is easier, just return $_. also you
> don't need to reference $_ when using s///.
>
> @f = map { s/"0000-00-00"/NULL/ ; $_} @f ;
This is what made sense to me to begin with, but when I tried it I
used () instead of {} like so:
@f = map (s/"0000-00-00"/NULL/ ; $_, @f);
and of course this won't compile. Then I tried
@f = map ($_ =~ s/"0000-00-00"/NULL/, @f);
which seems to return the number of elements replaced. My problem is I
failed to use the {} form instead of ().
This is why I used ?: .
> but for modifier to the rescue!
>
> s/"0000-00-00"/NULL/ for @f ;
>
> that modifies the elements in place.
I didn't realize that it would and didn't even try it.
Thanks.
--
Brandon
------------------------------
Date: Fri, 22 May 2009 11:31:45 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: edit array in place
Message-Id: <87pre1f926.fsf@quad.sysarch.com>
>>>>> "BM" == Brandon Metcalf <brandon@geronimoa11oys.invalid> writes:
BM> On 2009-05-21, Uri Guttman <uri@StemSystems.com> wrote:
>> @f = map { s/"0000-00-00"/NULL/ ; $_} @f ;
BM> This is what made sense to me to begin with, but when I tried it I
BM> used () instead of {} like so:
BM> @f = map (s/"0000-00-00"/NULL/ ; $_, @f);
map has two syntax forms. the simpler takes a single expression with a
trailing comma( no statement separators but a do block should work but is
overkill). the other takes a code block with no trailing comma. you can
put as much code in there as you want and the last evaluated
statement/expression is the value for that iteration of the map (and it
could be an empty list).
BM> and of course this won't compile. Then I tried
BM> @f = map ($_ =~ s/"0000-00-00"/NULL/, @f);
BM> which seems to return the number of elements replaced. My problem is I
BM> failed to use the {} form instead of ().
that makes sense as the value of the s/// is the number of replacements.
>> but for modifier to the rescue!
>>
>> s/"0000-00-00"/NULL/ for @f ;
>>
>> that modifies the elements in place.
BM> I didn't realize that it would and didn't even try it.
in map/grep/for (in fact anytime $_ is implied for looping), it is
aliased to its value so you can modify $_ and it modifies the original
value.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 22 May 2009 17:43:04 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: edit array in place
Message-Id: <o91je6-md3.ln1@osiris.mauzo.dyndns.org>
Quoth "Uri Guttman" <uri@StemSystems.com>:
>
> in map/grep/for (in fact anytime $_ is implied for looping), it is
> aliased to its value so you can modify $_ and it modifies the original
> value.
It's worth noting at this point (since it confused me when I first found
out) that 5.10's 'given' *doesn't* take an alias, it makes a copy.
Ben
------------------------------
Date: Fri, 22 May 2009 13:00:34 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: edit array in place
Message-Id: <87my95dqdp.fsf@quad.sysarch.com>
>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
BM> Quoth "Uri Guttman" <uri@StemSystems.com>:
>>
>> in map/grep/for (in fact anytime $_ is implied for looping), it is
>> aliased to its value so you can modify $_ and it modifies the original
>> value.
BM> It's worth noting at this point (since it confused me when I first found
BM> out) that 5.10's 'given' *doesn't* take an alias, it makes a copy.
good point. i haven't used given yet as i am not using new features in
5.10. i would love to use // but i generally code to older versions of
perl for my modules. hell, file::slurp is backwards compatible to 5.005
still and i aim to keep it that way.
also i wouldn't classify when as a loop as i commented above. maybe i
was lucky in saying loop aliases!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 22 May 2009 06:46:33 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <slrnh1d44p.oah.tadmc@tadmc30.sbcglobal.net>
Marc Girod <marc.girod@gmail.com> wrote:
> On May 21, 12:43 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
>> The language is called Perl. It is not an acronym.
>
> But from a linguistic point of view, let's note that
> it is a (probably intended) spelling error for
> 'pearl', which is what you might find valuable in a
> 'shell'.
The "a" was removed to avoid a conflict with an already-existing
language named pearl.
> There is certainly some amount of literature on this
> topic already...
Get it from the Camel's mouth:
http://www.linuxjournal.com/article/3394
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
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 2435
***************************************