[31770] in Perl-Users-Digest
Perl-Users Digest, Issue: 3033 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 16 16:20:03 2010
Date: Fri, 16 Jul 2010 13:19:51 -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, 16 Jul 2010 Volume: 11 Number: 3033
Today's topics:
Is there something like 'accumulate' in mit-scheme or C <pengyu.ut@gmail.com>
Re: Is there something like 'accumulate' in mit-scheme <tadmc@seesig.invalid>
Re: Is there something like 'accumulate' in mit-scheme <ben@morrow.me.uk>
Re: Is there something like 'accumulate' in mit-scheme <pengyu.ut@gmail.com>
Re: Is there something like 'accumulate' in mit-scheme <usenet.114983.david@distelpluis.nl>
Re: Is there something like 'accumulate' in mit-scheme <usenet.114983.david@distelpluis.nl>
Re: Is there something like 'accumulate' in mit-scheme <ben@morrow.me.uk>
Re: Is there something like 'accumulate' in mit-scheme sln@netherlands.com
map and grep again... <marc.girod@gmail.com>
Re: map and grep again... <sreservoir@gmail.com>
Re: map and grep again... <marc.girod@gmail.com>
Re: map and grep again... sln@netherlands.com
MasonCompRoot and globs <tw@dionic.net>
NEED JS <sooraj.logicplanet@gmail.com>
Re: NEED JS <tadmc@seesig.invalid>
NEED JSF RESUMAES <sooraj.logicplanet@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 Jul 2010 18:27:06 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <e3740fcc-2685-48a5-9049-df871d57931f@j8g2000yqd.googlegroups.com>
Hi,
I use the following command to OR the values in an array. I'm
wondering what is the best way to do so. A function similar to
'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
in perl.
my @array=(0,0,1);
my $result=0;
map { $result = $result || $_} @array;
print $result, "\n";
Regards,
Peng
------------------------------
Date: Thu, 15 Jul 2010 20:35:38 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <slrni3vdlh.ku7.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> I use the following command to OR the values in an array. I'm
> wondering what is the best way to do so. A function similar to
> 'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
> in perl.
>
> my @array=(0,0,1);
> my $result=0;
> map { $result = $result || $_} @array;
$result ||= $_ for @array; # map in void context is silliness anyway...
> print $result, "\n";
see the "Assignment Operators" section in
perldoc perlop
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 16 Jul 2010 03:12:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <5qr4h7-9131.ln1@osiris.mauzo.dyndns.org>
Quoth Peng Yu <pengyu.ut@gmail.com>:
> Hi,
>
> I use the following command to OR the values in an array. I'm
> wondering what is the best way to do so. A function similar to
> 'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
> in perl.
>
> my @array=(0,0,1);
> my $result=0;
> map { $result = $result || $_} @array;
> print $result, "\n";
The usual term for this operation is 'reduce'; you can find it in
List::Util. Note that you need to explicitly provide an initial value:
use List::Util qw/reduce/;
my $result = reduce { $a || $b } 0, @array;
In this case you could also use 'first':
use List::Util qw/first/;
my $result = first { $_ } 0, @array;
Ben
------------------------------
Date: Thu, 15 Jul 2010 22:07:06 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <18ff32ca-54c9-4a2c-a40a-c66bf176653b@i31g2000yqm.googlegroups.com>
On Jul 15, 9:12=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Peng Yu <pengyu...@gmail.com>:
>
> > Hi,
>
> > I use the following command to OR the values in an array. I'm
> > wondering what is the best way to do so. A function similar to
> > 'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
> > in perl.
>
> > my @array=3D(0,0,1);
> > my $result=3D0;
> > map { $result =3D $result || $_} @array;
> > print $result, "\n";
>
> The usual term for this operation is 'reduce'; you can find it in
> List::Util. Note that you need to explicitly provide an initial value:
>
> =A0 =A0 use List::Util qw/reduce/;
>
> =A0 =A0 my $result =3D reduce { $a || $b } 0, @array;
>
> In this case you could also use 'first':
>
> =A0 =A0 use List::Util qw/first/;
>
> =A0 =A0 my $result =3D first { $_ } 0, @array;
#!/usr/bin/env perl
use strict;
use warnings;
use List::Util;
my @array=3D1..10;
my $result=3DList::Util::reduce { $a + $b } @array;
print $result, "\n";
##########
I got the following warnings for the above problem. But the code from
the manual works. I'm wondering what is wrong in the above code?
Name "main::b" used only once: possible typo at ./main.pl line 8.
Name "main::a" used only once: possible typo at ./main.pl line 8.
my $result =3D List::Util::reduce { $a > $b ? $a : $b } 1..10;#this
works
------------------------------
Date: Fri, 16 Jul 2010 03:00:57 -0700 (PDT)
From: David Bouman <usenet.114983.david@distelpluis.nl>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <cb532d93-b522-4a1f-82f8-8bcec05a8aa9@s9g2000yqd.googlegroups.com>
On Jul 16, 3:27 am, Peng Yu <pengyu...@gmail.com> wrote:
> I use the following command to OR the values in an array. I'm
> wondering what is the best way to do so. A function similar to
> 'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
> in perl.
What about using a grep in scalar context?
--
David.
------------------------------
Date: Fri, 16 Jul 2010 03:01:09 -0700 (PDT)
From: David Bouman <usenet.114983.david@distelpluis.nl>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <27e8f9ba-8af6-445a-b879-5356ebcfb84d@u26g2000yqu.googlegroups.com>
On Jul 16, 3:27 am, Peng Yu <pengyu...@gmail.com> wrote:
> I use the following command to OR the values in an array. I'm
> wondering what is the best way to do so. A function similar to
> 'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
> in perl.
What about using a grep in scalar context?
--
David.
------------------------------
Date: Fri, 16 Jul 2010 17:53:03 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <fcf6h7-3ub1.ln1@osiris.mauzo.dyndns.org>
Quoth Peng Yu <pengyu.ut@gmail.com>:
> On Jul 15, 9:12 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> >
> > The usual term for this operation is 'reduce'; you can find it in
> > List::Util. Note that you need to explicitly provide an initial value:
> >
> > use List::Util qw/reduce/;
> >
> > my $result = reduce { $a || $b } 0, @array;
> >
> > In this case you could also use 'first':
> >
> > use List::Util qw/first/;
> >
> > my $result = first { $_ } 0, @array;
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use List::Util;
>
> my @array=1..10;
> my $result=List::Util::reduce { $a + $b } @array;
> print $result, "\n";
> ##########
>
> I got the following warnings for the above problem. But the code from
> the manual works. I'm wondering what is wrong in the above code?
>
> Name "main::b" used only once: possible typo at ./main.pl line 8.
> Name "main::a" used only once: possible typo at ./main.pl line 8.
This appears to be a bug in List::Util (I'll report it once I've
verified this). The workaround, as you have discovered, is to mention $a
and $b more than once in your program. Something entirely trivial like
$a, $b; # work around 'used only once' warning
will do.
Ben
------------------------------
Date: Fri, 16 Jul 2010 11:09:11 -0700
From: sln@netherlands.com
Subject: Re: Is there something like 'accumulate' in mit-scheme or C++?
Message-Id: <pf7146dm63dh7sgg3de45mmoui9neouu5q@4ax.com>
On Thu, 15 Jul 2010 18:27:06 -0700 (PDT), Peng Yu <pengyu.ut@gmail.com> wrote:
>Hi,
>
>I use the following command to OR the values in an array. I'm
>wondering what is the best way to do so. A function similar to
>'accumulate' in mit-scheme or C++, may be helpful. But I don't find it
>in perl.
>
>my @array=(0,0,1);
>my $result=0;
>map { $result = $result || $_} @array;
>print $result, "\n";
>
>Regards,
>Peng
I'm just wondering which would be faster:
$result ||= $_ and last for ( @array );
or
$result |= $_ and last for ( @array );
-sln
------------------------------
Date: Fri, 16 Jul 2010 07:50:10 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: map and grep again...
Message-Id: <ff83766a-bfa9-4ec3-897a-2888d5ba1472@j13g2000yqj.googlegroups.com>
Hello,
I know this has been explained earlier... but why are map and grep
behaving differently here?
#!/usr/bin/perl -w
use strict;
use feature qw(say);
my @glb = qw(lbtype:FFF);
say $_ for map { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
@glb = qw(lbtype:FFF);
say $_ for grep { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
Running this gives:
$ /tmp/foo
1
FFF
Thanks,
Marc
------------------------------
Date: Fri, 16 Jul 2010 11:05:59 -0400
From: sreservoir <sreservoir@gmail.com>
Subject: Re: map and grep again...
Message-Id: <i1pshb$mte$1@speranza.aioe.org>
On 7/16/2010 10:50 AM, Marc Girod wrote:
> Hello,
>
> I know this has been explained earlier... but why are map and grep
> behaving differently here?
>
> #!/usr/bin/perl -w
>
> use strict;
> use feature qw(say);
>
> my @glb = qw(lbtype:FFF);
> say $_ for map { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
map collect return values.
> @glb = qw(lbtype:FFF);
> say $_ for grep { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
grep collects when return value is true.
> Running this gives:
>
> $ /tmp/foo
> 1
> FFF
for (@glb) { s///; say }
of course. s/// return 1 or !1, depending whether something was matched
or replaced.
please don't use map and grep purely for side-effects unless you know
what you're doing.
and you don't have to specify the implicit argument.
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe."
------------------------------
Date: Fri, 16 Jul 2010 08:16:55 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: map and grep again...
Message-Id: <9d3857ca-2be8-4ea5-a978-3daa249ebddc@k39g2000yqd.googlegroups.com>
On Jul 16, 4:05=A0pm, sreservoir <sreserv...@gmail.com> wrote:
> map collect return values.
> grep collects when return value is true.
Thanks.
Marc
------------------------------
Date: Fri, 16 Jul 2010 10:32:41 -0700
From: sln@netherlands.com
Subject: Re: map and grep again...
Message-Id: <t3514610hv94g2deha01tt6pp24ckevk8s@4ax.com>
On Fri, 16 Jul 2010 07:50:10 -0700 (PDT), Marc Girod <marc.girod@gmail.com> wrote:
>Hello,
>
>I know this has been explained earlier... but why are map and grep
>behaving differently here?
>
>#!/usr/bin/perl -w
>
>use strict;
>use feature qw(say);
>
>my @glb = qw(lbtype:FFF);
>say $_ for map { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
>@glb = qw(lbtype:FFF);
>say $_ for grep { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
>
>Running this gives:
>
>$ /tmp/foo
>1
>FFF
>
>Thanks,
>Marc
map {} .. is going to give you the result of the operation.
The line with map is creating a list with the result of the
regular expression.
Grep is is creating a list of sucessfull matches.
You confuse the issue when you when you stick map or grep
inside the for expression then put the default $_ inside its
body. Obviously each is say(ing) the itterative list values
AFTER the list is created.
So,
say $_ for map { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
^^ is NOT { $_ =~ s/^lbtype:(.*)(\@.*)?$/$1/ }
^^
Nothing wrong with clarity.
print "----\n";
@glb = qw(lbtype:FFF);
@list = map { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
for (@list) {
say $_;
}
@glb = qw(lbtype:FFF);
@list = map { s/^lbtype:(.*)(\@.*)?$/$1/; $_ } @glb;
for (@list) {
say $_;
}
print "----\n";
@glb = qw(lbtype:FFF);
@list = grep { s/^lbtype:(.*)(\@.*)?$/$1/ } @glb;
for (@list) {
say $_;
}
-sln
------------------------------
Date: Thu, 15 Jul 2010 18:16:57 +0100
From: Tim Watts <tw@dionic.net>
Subject: MasonCompRoot and globs
Message-Id: <i1nfqa$965$2@news.eternal-september.org>
Hi,
Couldn't find this by searching... I'm a perl programmer, but trying
out Mason for the first time. Any Mason folk here?
[Posted to the Mason Users list but that looks almost dead]
I've got this in my Apache 2 config (ignore linewraps in email):
PerlAddVar MasonCompRoot
"html=>/vol/www/www.robertsbridge.org/html"
PerlAddVar MasonCompRoot
"liblocal=> /vol/www/www.robertsbridge.org/html/*/_mason"
PerlAddVar MasonCompRoot
"libglobal=>/vol/www/www.robertsbridge.org/_mason"
and it's not doing what I'd hoped...
What I want is:
--- /_test/_test.html ---
The value is: <& var.mas &>
-----
To search:
(docroot)/_test/_mason/
(docroot)/_mason/
/vol/www/www.robertsbridge.org/_mason
Look at the HTML::Mason::Resolver man page, I was under the impression
globs were allowed?
Or do I need to implement my own resolver?
On an aside, I'd like to access the resolver directly: eg, if I have a
menu.mas component that loads a menu.dat (a perl data structure), I'd
like to have it search in the current outermost component's directory
(eg the location of the .html file), then up a directory, then up until
it hits the DocumentRoot until it finds one.
Any tips on whether I can leverage Mason for this, or do I do it the
"hard" way in perl by making my own search routine?
Many thanks. So far very impressed with Mason :)
Cheers
Tim
--
Tim Watts
------------------------------
Date: Thu, 15 Jul 2010 10:49:42 -0700 (PDT)
From: sooraj <sooraj.logicplanet@gmail.com>
Subject: NEED JS
Message-Id: <ea80965e-4981-4589-b994-b9b75dc2d124@z15g2000prn.googlegroups.com>
Please Reply to Sooraj@logicplanet.com
Hi Partners,
Hope you are doing great!!!
Please let me know if you have any suitable consultants for below
position
J2EE Developer with JSF Exp
Trenton, NJ
long term
DES:
6+ Years of experience with J2EE stack
Strong Java web interface development skills - MVC patterns, Servlets,
JSPs, HTML, JavaScript, and CSS
3+ years of experience implementing Java Server Faces (JSF version
1.1 and 1.2), Spring Webflow, RichFaces components and Facelets
2+ Years hands on experience with Spring
2+ Year hands on experience with EJBs
2+ years hands on experience with ORM support with JPA and Hibernate
and exposure to Hibernate tools.
1+ year experience of using jUnit
1+ year experience with Web Services development
Experience of creating and maintaining maven script for development,
building, testing and deployment.
Experience using IBM Rational Application Developer a plus
Experience in creating UML diagrams using Rational suite a plus.
Working knowledge of relational database systems including Oracle.
Database knowledge should include mastery of SQL, exposure to database
schema design, and understanding differences in application
interaction with Oracle, writing stored procedures.
Experience on Websphere Application server is a plus
Exposure to JMS and WebSphere MQ is a plus
Exposure to WebSphere ESB is a plus
Exposure to EJB 3.0 is a plus.
Exposure to sun solaris and AIX o/s is a plus.
Knowledge of FileNet content manager is a plus
Knowledge of JRule Rule Engine is a plus
Knowledge of Sun Identity Management, BPM, and reporting tools like
Crystal/BI is a plus
Thanks & Regards,
Sooraj
Logic Planet Inc.
45 Brunswick Ave,
Suite# 130
Edison, NJ 08817
Email: Sooraj@logicplanet.com
IM: Sooraj086
URL: www.logicplanet.com
If we are together nothing is impossible. If we are divided all will
fail.
Logic Planet ranked over all 719 in Inc 500/5000.
Logic Planet ranked 98 on Inc 100 Software Companies.
Logic Planet ranked 56 on Inc 100 NJ/NY/PA area.
------------------------------
Date: Thu, 15 Jul 2010 15:16:57 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: NEED JS
Message-Id: <slrni3ur00.jhj.tadmc@tadbox.sbcglobal.net>
sooraj <sooraj.logicplanet@gmail.com> wrote:
> Subject: NEED JS
> Newsgroups: comp.lang.perl.misc
Are you clueful enough to tell the difference between Perl and
Javascript?
Apparently not!
> Please Reply to Sooraj@logicplanet.com
Please post from Sooraj@logicplanet.com then.
We are not here to jump through your hoops.
> Hi Partners,
You are rather too presumptuous.
> Hope you are doing great!!!
Yeah, right.
Repeating punctuation characters is sure to convey sincerity...
> Please let me know if you have any suitable consultants for below
> position
Job postings are not welcome in Usenet discussion newsgroups, there
are other newsgroups (with "jobs" in their name) for that.
Everyone with clue know this, yet you do not.
Most folks will not want to work with a recruiter that has
clearly demonstrated cluelessness.
You would have placed more people if you had never posted this!
> Logic Planet
is a spammer, just as con artists and pornographers are spammers.
Not the type of folks a reputable business would want to be seen
emulating..
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 15 Jul 2010 10:53:14 -0700 (PDT)
From: sooraj <sooraj.logicplanet@gmail.com>
Subject: NEED JSF RESUMAES
Message-Id: <d75ad833-a3fc-47d4-9a4c-c95438f90e85@x24g2000pro.googlegroups.com>
Please Reply to Sooraj@logicplanet.com
Hi Partners,
Hope you are doing great!!!
Please let me know if you have any suitable consultants for below
position
J2EE Developer with JSF Exp
Trenton, NJ
long term
DES:
6+ Years of experience with J2EE stack
Strong Java web interface development skills - MVC patterns,
Servlets, JSPs, HTML, JavaScript, and CSS
3+ years of experience implementing Java Server Faces (JSF version
1.1 and 1.2), Spring Webflow,RichFaces components and Facelets
2+ Years hands on experience with Spring
2+ Year hands on experience with EJBs
2+ years hands on experience with ORM support with JPA and Hibernate
and exposure to Hibernate tools.
1+ year experience of using jUnit
1+ year experience with Web Services development
Experience of creating and maintaining maven script for development,
building, testing and deployment.
Experience using IBM Rational Application Developer a plus
Experience in creating UML diagrams using Rational suite a plus.
Working knowledge of relational database systems including Oracle.
Database knowledge should include mastery of SQL, exposure to database
schema design, and understanding differences in application
interaction with Oracle, writing stored procedures.
Experience on Websphere Application server is a plus
Exposure to JMS and WebSphere MQ is a plus
Exposure to WebSphere ESB is a plus
Exposure to EJB 3.0 is a plus.
Exposure to sun solaris and AIX o/s is a plus.
Knowledge of FileNet content manager is a plus
Knowledge of JRule Rule Engine is a plus
Knowledge of Sun Identity Management, BPM, and reporting tools like
Crystal/BI is a plus
Thanks & Regards,
Sooraj
Logic Planet Inc.
45 Brunswick Ave,
Suite# 130
Edison, NJ 08817
Email: Sooraj@logicplanet.com
IM: Sooraj086
URL: www.logicplanet.com
If we are together nothing is impossible. If we are divided all will
fail.
Logic Planet ranked over all 719 in Inc 500/5000.
Logic Planet ranked 98 on Inc 100 Software Companies.
Logic Planet ranked 56 on Inc 100 NJ/NY/PA area.
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3033
***************************************