[31604] in Perl-Users-Digest
Perl-Users Digest, Issue: 2863 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 16:09:27 2010
Date: Wed, 10 Mar 2010 13:09:11 -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, 10 Mar 2010 Volume: 11 Number: 2863
Today's topics:
Re: Can you compile a perl executable? <hjp-usenet2@hjp.at>
Re: Detecting Bourne (or csh) shell from Perl <nospam-abuse@ilyaz.org>
grep an array of hashrefs <monkey@joemoney.net>
Re: grep an array of hashrefs <john@castleamber.com>
Re: grep an array of hashrefs <jurgenex@hotmail.com>
Re: Still looking for a function-type MySQL interface <uri@StemSystems.com>
Re: Still looking for a function-type MySQL interface <rvtol+usenet@xs4all.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Mar 2010 19:46:14 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Can you compile a perl executable?
Message-Id: <slrnhpfq7n.o30.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-09 09:19, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> Peter J. Holzer wrote:
>> On 2010-03-03 09:00, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
>>> Jürgen Exner wrote:
>>>> Steve <steve@staticg.com> wrote:
>>>>> If I made an application, and wanted to make it portable, is it
>>>>> possible to compile it into a single binary?
>>>> See "perldoc -q compile":
>>>> "How can I compile my Perl program into byte code or C?"
>>>>
>>> I note that this perldoc appears to be happy
>>> that B::Bytecode is the way to do this,
>>
>> Not in the current version. That paragraph vanished sometime between
>> 5.8.8 and 5.10.0
>
> You mean the perldoc recommending B::Bytecode has
> changed, or the warning in B::Bytecode?
The former. See for yourself at
http://perldoc.perl.org/perlfaq3.html#How-can-I-compile-my-Perl-program-into-byte-code-or-C?
hp
------------------------------
Date: Wed, 10 Mar 2010 20:22:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Detecting Bourne (or csh) shell from Perl
Message-Id: <slrnhpfvrl.gjt.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-03-09, Ben Morrow <ben@morrow.me.uk> wrote:
>> BTW, let me clarify: I suspect what is a "Unix emulation layer" for
>> Ben is just "implementation of POSIX APIs on top of
>> `(the-given-)system'-calls" for me...
>
> No. I consider Cygwin &c. emulation layers because they don't just
> provide libc, they also remap the filesystem[0] and (attempt to) provide
> Unixish kernel-level services like fork and ptys which aren't
> implemented in NT.
You just confirm my statement: I do not care what is kernel-level and
what not (same as a Perl script - it would not care). You do.
> From the point of view of an application program like
> perl, Cygwin behaves a lot more like a rather strange Unix than it does
> like some variant of Win32, which is why $^O is different.
IMO, any Perl port must be "just a strange flavor" of another port (as
far as possible). All significant differences must be triggered
explicitly, by pragmas.
Yours,
Ilya
------------------------------
Date: Wed, 10 Mar 2010 12:59:51 -0500
From: monkeys paw <monkey@joemoney.net>
Subject: grep an array of hashrefs
Message-Id: <L56dnQq2vsyBQwrWnZ2dnUVZ_u6dnZ2d@insightbb.com>
Here is the code i have to find if a hash element
is present in an array of hashrefs:
my @return_set = (
{
'topic' => '40604',
'id_type' => 'bill',
'topic_list' => '',
'id' => 'CA2009000A34'
},
{
'topic' => '40604',
'id_type' => 'bill',
'topic_list' => '',
'id' => 'CA2009000A126'
},
{
'topic' => '40604',
'id_type' => 'bill',
'topic_list' => '',
'id' => 'CA2009000A293'
},
);
my @tmp_array;
for (@return_set) {
push @tmp_array, $_->{id};
}
my $key = 'CA2009000A293';
if (grep /$key/, @tmp_array) {
print 'yestru';
}
How can i use grep on the original array (@return_set), instead of
building a flat array.
------------------------------
Date: Wed, 10 Mar 2010 12:22:52 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: grep an array of hashrefs
Message-Id: <87r5nsujcz.fsf@castleamber.com>
monkeys paw <monkey@joemoney.net> writes:
> Here is the code i have to find if a hash element
> is present in an array of hashrefs:
>
> my @return_set = (
> {
> 'topic' => '40604',
> 'id_type' => 'bill',
> 'topic_list' => '',
> 'id' => 'CA2009000A34'
> },
> {
> 'topic' => '40604',
> 'id_type' => 'bill',
> 'topic_list' => '',
> 'id' => 'CA2009000A126'
> },
> {
> 'topic' => '40604',
> 'id_type' => 'bill',
> 'topic_list' => '',
> 'id' => 'CA2009000A293'
> },
>
> );
>
> my @tmp_array;
> for (@return_set) {
> push @tmp_array, $_->{id};
> }
>
> my $key = 'CA2009000A293';
> if (grep /$key/, @tmp_array) {
> print 'yestru';
> }
>
> How can i use grep on the original array (@return_set), instead of
> building a flat array.
perldoc -f grep
grep { $_->{ id } eq $key } @return_set;
but if you just want to test if the key is present, you might want to
use List::MoreUtils 'any';
if ( any { $_->{ id } eq $key } @return_set ) {
print 'yestru';
}
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Wed, 10 Mar 2010 10:45:49 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: grep an array of hashrefs
Message-Id: <9upfp55hj6rl9aa0b032kpthtt8id6rff0@4ax.com>
monkeys paw <monkey@joemoney.net> wrote:
>Here is the code i have to find if a hash element
>is present in an array of hashrefs:
>How can i use grep on the original array (@return_set), instead of
>building a flat array.
The first argument to grep() is not a restricted to an RE but can be any
expression. So just dig down in that expression (untested):
grep ( $_->{id} eq 'CA2009000A293', @return_set);
jue
------------------------------
Date: Wed, 10 Mar 2010 12:06:59 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Still looking for a function-type MySQL interface
Message-Id: <878wa05cng.fsf@quad.sysarch.com>
>>>>> "LE" == Lars Eighner <usenet@larseighner.com> writes:
>> There are lots of CPAN entries for database stuff. What have you found?
LE> More than 1100 entries, but a many of the as I have inspected seem
LE> to involve minus greater-than notation. As I said, I am looking
LE> for a function-type database interface.
why do you care about this? it isn't called 'minus greater-than
notation' but OO. it is actually EASIER to use oo for this than
procedural. and DBI is the standard interface to dozens of db systems so
you can actually switch to another (if your sql is portable
enough). your request makes little sense for that reason.
and there is a module out there that will wrap an OO module into a
procedural one (it assumes a default object for it). you can easily use
it (i need to find it, i do think i know the author) or write your
own. just allocate a singleton object in a lexical and all your
procedural wrapper subs use it to make the OO calls. you save on passing
the object and the dreaded -> notation but you lose on everything else.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 10 Mar 2010 21:28:38 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Still looking for a function-type MySQL interface
Message-Id: <4b9800f6$0$22945$e4fe514c@news.xs4all.nl>
Lars Eighner wrote:
> More than 1100 entries, but a many of the as I have inspected seem to
> involve minus greater-than notation. As I said, I am looking for a
> function-type database interface.
But why?
It is easy to abstract away yourself though.
Or see DBIx::Perlish.
--
Ruud
------------------------------
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 2863
***************************************