[18017] in Perl-Users-Digest
Perl-Users Digest, Issue: 177 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 30 18:06:32 2001
Date: Tue, 30 Jan 2001 15:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980895916-v10-i177@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 30 Jan 2001 Volume: 10 Number: 177
Today's topics:
"how can I customize my installation of ActivePerl" <loy_x@yahoo.com>
Re: "how can I customize my installation of ActivePerl" <amonotod@netscape.net>
Re: 'apply' function in perl? <perin@panix.com>
Re: assistance reqd with perl cgi ($) (David H. Adler)
Re: BerkeleyDB vs. DB_File (cat does battle with self?) <nospam@ucdavis.edu>
Re: calling variable subroutines <kstep@pepsdesign.com>
Re: Can't use 'pop' as hash key oakbox@my-deja.com
Re: code review request <peter.sundstrom@eds.com>
Re: copying an array of hashes <mothra@nowhereatall.com>
Re: Creating calendar (reminder) class (Garry Williams)
Re: Creating calendar (reminder) class <marc.beck@bigfoot.com>
Re: Finding a char in string.. OMG <Yazum@Hotmail.com>
Re: Finding a char in string.. OMG <Yazum@Hotmail.com>
Re: Finding a char in string <amonotod@netscape.net>
Re: HELP Read from file on different server? (David Efflandt)
Re: help! Capturing matched content in regex (with doub napofrog@my-deja.com
Re: how do I temporarily close part of my site? <dcs@ntlworld.com>
io_multihomed.t fails with make test <rob@mcclear.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Jan 2001 11:38:40 -0800
From: news <loy_x@yahoo.com>
Subject: "how can I customize my installation of ActivePerl"
Message-Id: <3A771840.7EBF3F3C@yahoo.com>
The link in the docs (found here
http://velocity.activestate.com/docs/ActivePerl/faq/ActivePerl-faq1.html)
labelled "how can I customize my installation..." doesn't point
anywhere. Does anyone know where I can find this documentation?
Thanks.
------------------------------
Date: Tue, 30 Jan 2001 22:50:29 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: "how can I customize my installation of ActivePerl"
Message-Id: <957gfh$v71$1@nnrp1.deja.com>
In article <3A771840.7EBF3F3C@yahoo.com>,
news <loy_x@yahoo.com> wrote:
> The link in the docs (found here
>
http://velocity.activestate.com/docs/ActivePerl/faq/ActivePerl-faq1.html
)
> labelled "how can I customize my installation..." doesn't point
> anywhere. Does anyone know where I can find this documentation?
> Thanks.
>
>
file:///<install_dir>|/Perl/html/Perl-Win32/perlwin32faq1.html#How_can_I
_customize_my_installat
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 30 Jan 2001 17:00:06 -0500
From: Lewis Perin <perin@panix.com>
Subject: Re: 'apply' function in perl?
Message-Id: <pc7y9vs1z15.fsf@panix2.panix.com>
mjd@plover.com (Mark Jason Dominus) writes:
> In article <3a71ed40$1@news.microsoft.com>, Jürgen Exner <juex@deja.com> wrote:
> >"Greg Bacon" <gbacon@HiWAAY.net> wrote in message
> >news:t73mn8ubgc3f3@corp.supernews.com...
> >> What are you? Some kinda anti-loopite? :-) mjd wrote[*] a Perl
> >> version of reduce, and you could use that:
> >>
> >> my @nums = (1, 5, 14, 17, 7, -2);
> >> my $sum = reduce { $a + $b } 0, @nums;
> >>
> >> If only Perl had curried functions... :-)
> >
> >Out of curiosity: would it be possible to somehow use closures for this
> >purpose (or am I way off)?
> >
>
> You are right on the button. The reduce function Greg was alluding to
> looks like this:
>
> sub reduce (&$@) {
> my $code = shift;
> local $a = shift;
>
> for (@_) {
> local $b = $_;
> $a = &$code;
> }
>
> $a;
> }
>
>
> But it's easy to make a curried version:
>
>
> sub reduce (&$@) {
> my $code = shift;
> my $r1 = sub {
> my $id = shift;
> my $r2 = sub {
> local $a = $id;
>
> for (@_) {
> local $b = $_;
> $a = &$code;
> }
>
> $a;
> };
> return @_ ? $r2->(@_) : $r2;
> };
> return @_ ? $r1->(@_) : $r1;
> }
Might it not be nice to have a curried version without locals:
sub seduce (&$@) {
my $code = shift;
my $r1 = sub {
my $id = shift;
my $r2 = sub {
my $a = $id;
for (@_) {
$a = &$code($a, $_);
}
$a;
};
return @_ ? $r2->(@_) : $r2;
};
return @_ ? $r1->(@_) : $r1;
}
>
> Now you can call
>
> reduce { $a + $b } 0, (1,4,2,8,5,7);
seduce { $_[0] + $_[1] } 0 , (1,4,2,8,5,7);
> as before (it returns 27) but you can also call
>
>
> $sum = reduce { $a + $b } 0;
my $rum = seduce { $_[0] + $_[1] } 0;
> and you get back a function which, when invoked as
>
> $sub->(1,4,2,8,5,7)
$rum->(1,4,2,8,5,7) or &$rum(1,4,2,8,5,7)
> returns 27.
Ditto.
/Lew
--
Lew Perin / perin@mail.med.cornell.edu / perin@acm.org
www.panix.com/~perin/
------------------------------
Date: 30 Jan 2001 19:19:43 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: assistance reqd with perl cgi ($)
Message-Id: <slrn97e4uf.56.dha@panix2.panix.com>
On Tue, 30 Jan 2001 17:28:19 +0000, Jacob Jay - Enigma wrote:
> We need someone who is prepared to
>take a look at the script and get it running on our server (FreeBSD)
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
And, I also forgot to mention that P[ower]P[uff]G[irls] kick serious
booty. If for no other reason than: Bubbles talks to squirrels.
- Mark Rogaski
------------------------------
Date: Tue, 30 Jan 2001 11:15:14 -0800
From: Bruce McEachern <nospam@ucdavis.edu>
Subject: Re: BerkeleyDB vs. DB_File (cat does battle with self?)
Message-Id: <3A7712C2.15E9233F@ucdavis.edu>
--------------B58F5FA6B8E86D614715B9D7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Just in case anyone is interested:
The solution came in understanding that (at least under OSF-Tru64) when building
an `.so' (or an executable incorporating `.so's, as opposed to an archive (`.a')
or a fully resolve executable) the linker always searches the library search path
for `.so's first, before checking for `.a's. Thus, even though /usr/local/lib was
specified in the path before /usr/shlib, even when Perl itself was being built,
the perl executable ended up linked to the `.so' in /usr/shlib instead of the
intended--`.a' from the BerkeleyDB `.a' in /usr/local/lib.
I mention this in this public forum since this may become a general problem for
folks due to the fact that the default build mode appears to have changed from
`.a' (ie, a static perl executable) in 5.005 to `.so' (a dynamically linked perl)
in 5.6--at least it did for me.
Cheers to all,
Bruce
--------------------------------------------------------------------
Bruce McEachern >> brucem_at_library_ucdavis_edu <<
Library Systems Department The older I get, the better I...was.
Univ. of California, Davis Youth is fleeting
Phone: (916) 752-7685 --immaturity can last a lifetime.
--------------------------------------------------------------------
Bruce McEachern wrote:
> I have run into a problem installing/accessing/using Berkeley DB v3.1(.17), the
> Perl (v5.6.0) and BerkeleyDB module (0.12) to access it on a Tru64 Unix (v4.0f)
> box. The problem is that when I try to run something using the BerkeleyDB module
>
> (say, the "make test" suite), I get instant failure, with a message of the form:
>
> <snip edited="to fit screen">
> /usr/local/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/Perl5.6/lib
> -I/usr/local/Perl5.6/lib -e 'use Test::Harness qw(&runtests $verbose);
> $verbose=0; runtests "t/btree.t";'
> t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so'
> for module BerkeleyDB: Unresolved symbol in
> blib/arch/auto/BerkeleyDB/BerkeleyDB.so: db_create at
> /usr/local/Perl5.6/lib/DynaLoader.pm line 200.
> at t/btree.t line 25
> Compilation failed in require at t/btree.t line 25.
> BEGIN failed--compilation aborted at t/btree.t line 25.
> t/btree.............dubious
> Test returned status 255 (wstat 65280, 0xff00)
> FAILED--1 test script could be run, alas--no output ever seen
> </snip>
>
> After a good bit of thrashing about, I believe that this comes about because
> the perl, when configured and built, finds the OSF proffered libdb.so (in
> /usr/shlib), a Berkeley DB v1.85 would be my guess, and links to it. This I
> know, since ./Configure asks you to confirm a link switch containing:
>
> ... -ldb ... (that, and I checked the config files).
>
> What I think is happening is that Perl, when launching, hauls in the v1.85
> libdb.so (or at least the link table). Then, afterward, when the loader is
> trying to resolve symbols (found in BerkeleyDB.so)--particularly db_create--
> it knows it already has libdb loaded and does not try again. (FYI, it does not
> appear that db_create was a defined entity in v1.85.) So, even though I have
> told the configure/make of BerkeleyDB.so about where the v3.1.17 libdb.a lives,
> and my ENV yells LD_LIBRARY_PATH and screams LD_RUN_PATH at the loader, the
> above error just keeps on truckin' across my screen.
>
> Beyond the obvious question: "does this explanation make sense?," I am
> wondering about the most rational, sustainable, fix.
>
> Do I want to pull the "-ldb" out of the Perl configure and just leave all
> Berkeley DB access to be handled by BerkeleyDB.so (a v0.12, I might point out
> here)? Wouldn't this break a bunch of "simple-API" stuff available through the
> DB_File module? I'm fairly sure I can't just flip the v3.1.17 libdb.a into the
> front of the loader's search path and rebuild perl and all (it's not nice to
> jump up 2 major revs on libraries your O/S uses--usually).
>
> Any thoughts on this would be truly appreciated.
>
> Bruce (make the obvious alterations_\/_to get my e-mail addr)
> --------------------------------------------------------------------
> Bruce McEachern >> brucem_at_library_ucdavis_edu <<
> Library Systems Department The older I get, the better I...was.
> Univ. of California, Davis Youth is fleeting
> Phone: (916) 752-7685 --immaturity can last a lifetime.
> --------------------------------------------------------------------
--
--------------B58F5FA6B8E86D614715B9D7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt><font size=-1>Just in case anyone is interested:</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>The solution came in understanding that (at least
under OSF-Tru64) when building</font></tt>
<br><tt><font size=-1>an `.so' (or an executable incorporating `.so's,
as opposed to an archive (`.a')</font></tt>
<br><tt><font size=-1>or a fully resolve executable) the linker always
searches the library search path</font></tt>
<br><tt><font size=-1>for `.so's first, before checking for `.a's. Thus,
even though /usr/local/lib was</font></tt>
<br><tt><font size=-1>specified in the path before /usr/shlib, even when
Perl itself was being built,</font></tt>
<br><tt><font size=-1>the perl executable ended up linked to the `.so'
in /usr/shlib instead of the</font></tt>
<br><tt><font size=-1>intended--`.a' from the BerkeleyDB `.a' in /usr/local/lib.</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>I mention this in this public forum since this may
become a general problem for</font></tt>
<br><tt><font size=-1>folks due to the fact that the default build mode
appears to have changed from</font></tt>
<br><tt><font size=-1>`.a' (ie, a static perl executable) in 5.005 to `.so'
(a dynamically linked perl)</font></tt>
<br><tt><font size=-1>in 5.6--at least it did for me.</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Cheers to all,</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Bruce</font></tt>
<br><tt><font size=-1>--------------------------------------------------------------------</font></tt>
<br><tt><font size=-1>Bruce McEachern
>> brucem_at_library_ucdavis_edu <<</font></tt>
<br><tt><font size=-1>Library Systems Department
The older I get, the better I...was.</font></tt>
<br><tt><font size=-1>Univ. of California, Davis
Youth is fleeting</font></tt>
<br><tt><font size=-1>Phone: (916) 752-7685
--immaturity can last a lifetime.</font></tt>
<br><tt><font size=-1>--------------------------------------------------------------------</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Bruce McEachern wrote:</font></tt>
<blockquote TYPE=CITE><tt><font size=-1>I have run into a problem installing/accessing/using
Berkeley DB v3.1(.17), the</font></tt>
<br><tt><font size=-1>Perl (v5.6.0) and BerkeleyDB module (0.12) to access
it on a Tru64 Unix (v4.0f)</font></tt>
<br><tt><font size=-1>box. The problem is that when I try to run something
using the BerkeleyDB module</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>(say, the "make test" suite), I get instant failure,
with a message of the form:</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1><snip edited="to fit screen"></font></tt>
<br><tt><font size=-1>/usr/local/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/Perl5.6/lib</font></tt>
<br><tt><font size=-1> -I/usr/local/Perl5.6/lib -e 'use
Test::Harness qw(&runtests $verbose);</font></tt>
<br><tt><font size=-1> $verbose=0;
runtests "t/btree.t";'</font></tt>
<br><tt><font size=-1>t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so'</font></tt>
<br><tt><font size=-1> for module BerkeleyDB: Unresolved
symbol in</font></tt>
<br><tt><font size=-1> blib/arch/auto/BerkeleyDB/BerkeleyDB.so:
db_create at</font></tt>
<br><tt><font size=-1>
/usr/local/Perl5.6/lib/DynaLoader.pm line 200.</font></tt>
<br><tt><font size=-1> at t/btree.t line 25</font></tt>
<br><tt><font size=-1>Compilation failed in require at t/btree.t line 25.</font></tt>
<br><tt><font size=-1>BEGIN failed--compilation aborted at t/btree.t line
25.</font></tt>
<br><tt><font size=-1>t/btree.............dubious</font></tt>
<br><tt><font size=-1> Test returned
status 255 (wstat 65280, 0xff00)</font></tt>
<br><tt><font size=-1>FAILED--1 test script could be run, alas--no output
ever seen</font></tt>
<br><tt><font size=-1></snip></font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>After a good bit of thrashing about, I believe that
this comes about because</font></tt>
<br><tt><font size=-1>the perl, when configured and built, finds the OSF
proffered libdb.so (in</font></tt>
<br><tt><font size=-1>/usr/shlib), a Berkeley DB v1.85 would be my guess,
and links to it. This I</font></tt>
<br><tt><font size=-1>know, since ./Configure asks you to confirm a link
switch containing:</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1> ... -ldb ... (that, and I
checked the config files).</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>What I think is happening is that Perl, when launching,
hauls in the v1.85</font></tt>
<br><tt><font size=-1>libdb.so (or at least the link table). Then, afterward,
when the loader is</font></tt>
<br><tt><font size=-1>trying to resolve symbols (found in BerkeleyDB.so)--particularly
db_create--</font></tt>
<br><tt><font size=-1>it knows it already has libdb loaded and does not
try again. (FYI, it does not</font></tt>
<br><tt><font size=-1>appear that db_create was a defined entity in v1.85.)
So, even though I have</font></tt>
<br><tt><font size=-1>told the configure/make of BerkeleyDB.so about where
the v3.1.17 libdb.a lives,</font></tt>
<br><tt><font size=-1>and my ENV yells LD_LIBRARY_PATH and screams LD_RUN_PATH
at the loader, the</font></tt>
<br><tt><font size=-1>above error just keeps on truckin' across my screen.</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Beyond the obvious question: "does this explanation
make sense?," I am</font></tt>
<br><tt><font size=-1>wondering about the most rational, sustainable, fix.</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Do I want to pull the "-ldb" out of the Perl configure
and just leave all</font></tt>
<br><tt><font size=-1>Berkeley DB access to be handled by BerkeleyDB.so
(a v0.12, I might point out</font></tt>
<br><tt><font size=-1>here)? Wouldn't this break a bunch of "simple-API"
stuff available through the</font></tt>
<br><tt><font size=-1>DB_File module? I'm fairly sure I can't just flip
the v3.1.17 libdb.a into the</font></tt>
<br><tt><font size=-1>front of the loader's search path and rebuild perl
and all (it's not nice to</font></tt>
<br><tt><font size=-1>jump up 2 major revs on libraries your O/S uses--usually).</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Any thoughts on this would be truly appreciated.</font></tt><tt><font size=-1></font></tt>
<p><tt><font size=-1>Bruce (make the
obvious alterations_\/_to get my e-mail addr)</font></tt>
<br><tt><font size=-1>--------------------------------------------------------------------</font></tt>
<br><tt><font size=-1>Bruce McEachern
>> brucem_at_library_ucdavis_edu <<</font></tt>
<br><tt><font size=-1>Library Systems Department
The older I get, the better I...was.</font></tt>
<br><tt><font size=-1>Univ. of California, Davis
Youth is fleeting</font></tt>
<br><tt><font size=-1>Phone: (916) 752-7685
--immaturity can last a lifetime.</font></tt>
<br><tt><font size=-1>--------------------------------------------------------------------</font></tt></blockquote>
<tt><font size=-1>--</font></tt></html>
--------------B58F5FA6B8E86D614715B9D7--
------------------------------
Date: Tue, 30 Jan 2001 15:58:32 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: calling variable subroutines
Message-Id: <9579ph$34v$1@slb6.atl.mindspring.net>
"Neil" <neil@alaweb.com> wrote in message
news:t7e1i8rb1socb@corp.supernews.com...
> Hello,
>
> What I would like to do is create a loop in the manner of
> # do the sub we ask with the params we ask, and return the results
> # assume that we have variable number and types for the return and
send
First read perlref for info on creating references to subroutines, then
perhaps perlsub as well. References to subroutines allow you to implement
callbacks, closures, vtables and other cool stuff. Below is some sample
code that won't solve your problem but may inspire your imagination.
<< BEGIN CODE >>
use strict;
use warnings;
sub function_a {
print "Called function A";
print " with args (",
join(", ", map {"'$_'"} @_), ")" if @_;
print "\n";
}
sub function_b {
print "Called function B";
print " with args (",
join(", ", map {"'$_'"} @_), ")" if @_;
print "\n";
}
sub function_c {
print "Called function C";
print " with args (",
join(", ", map {"'$_'"} @_), ")" if @_;
print "\n";
}
print "A simple example...\n";
my %handlers = (
a => \&function_a,
b => \&function_b,
c => \&function_c,
);
foreach (qw(a c b a)) {
my $handler = $handlers{$_};
$handler->();
}
print "Now for some args...\n";
my @calls = (
['a', ['one', 'two', 'three']],
['b', ['foo', 'bar']],
['c', ['ready', 'steady', 'go']],
['a', ['Only one arg']],
);
foreach (@calls) {
my $handler = $handlers{$_->[0]};
my $args = $_->[1];
$handler->(@$args);
}
print "Line noise ahead...\n";
$handlers{$_->[0]}->(@{$_->[1]}) for @calls;
<< END CODE >>
HTH,
Kurt Stephens
------------------------------
Date: Tue, 30 Jan 2001 19:24:45 GMT
From: oakbox@my-deja.com
Subject: Re: Can't use 'pop' as hash key
Message-Id: <9574dh$j6d$1@nnrp1.deja.com>
Thank you for breaking this out for me!
use strict; took care of it.
Richard Still
http://www.oakbox.com
In article <u9r91muq20.fsf@wcl-l.bham.ac.uk>,
nobull@mail.com wrote:
> oakbox@my-deja.com writes:
>
> > I tried to use the word 'pop' as a key in a hash,
>
> You are not analysing your problem correctly.
>
> You tried to use 'pop' it as a bareword string constant in a list.
> The fact that you put that list into an array and at some later stage
> tried to use the elements of that array as a keys of a hash is
> irrelevant.
>
> > Are their reserved words that cannot be hash keys?
>
> No, but in older versions of Perl $fields{pop} is interpreted as
> $fields{pop()} rather than $fields{'pop'}. This is probably what you
> are vaguely recalling,
>
> Put "use strict" at the top of your script to disable bareword string
> contants altogether and you will not have this problem again.
>
> > @key_vals=(name,address,phone,pop);
>
> Should be:
>
> @key_vals=('name','address','phone','pop');
>
> Or
>
> @key_vals=qw( name address phone pop );
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
>
--
"There is more to life than increasing its speed." - Mahatma Gandhi
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 31 Jan 2001 09:50:40 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: code review request
Message-Id: <9579f1$cpn$1@hermes.nz.eds.com>
"Stephen Deken" <shutupsteve@aNwOdSaPnAgM.com> wrote in message
news:YMsd6.84289$lV5.1638367@news2.giganews.com...
> > Also I didn't notice how you acquired $user{email}; since
> > you're passing that to the shell it should be handled carefully
> > as well.
>
> That gets pulled from the database in getuserinfo(). I would probably do
> well to check it before I call sendmail, you're absolutely right. Isn't
> there some nice big regex that will check for the adherence of an email
> address to the RFC?
See
http://search.cpan.org/search?dist=Email-Valid
http://search.cpan.org/search?dist=Mail-CheckUser
------------------------------
Date: Tue, 30 Jan 2001 12:07:13 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: copying an array of hashes
Message-Id: <3A771EF1.5F214963@nowhereatall.com>
Philip Blandford wrote:
>
> I have an array of hashes @x, and want to create a spare copy @y so that
> changes I make to the hashes in @x don't affect @y.
>
> I realise there's probably a messy way to do it by dereferencing each
> field in the hash in turn, but this needs to be inside a repeating loop,
> so that could get VERY time consuming.
>
> Is there no Perl equivalent of memcpy?
you might want to take a look at the Storable module dclone function for
this
Mothra
------------------------------
Date: Tue, 30 Jan 2001 21:20:37 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Creating calendar (reminder) class
Message-Id: <FeGd6.4690$GF2.66604@eagle.america.net>
On Tue, 30 Jan 2001 20:03:26 +0100, Marc Beck <marc.beck@bigfoot.com> wrote:
>>
>> Event->timer( cb => \&msg, at => $time );
[snip]
>How can I code this that it will work?
>my $reminder = Event->timer( at => $time, cb => \&msg('World') );
>sub msg()
>{
> print "Hello $_[0]!";
>}
my $reminder = Event->timer(
at => $time,
cb => \&msg,
data => 'World',
);
sub msg {
my $event = $_[0];
my $text = $event->w->data;
print "Hello $text!";
}
--
Garry Williams
------------------------------
Date: Tue, 30 Jan 2001 22:51:15 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Re: Creating calendar (reminder) class
Message-Id: <957d0f$g62bp$1@ID-23826.news.dfncis.de>
> my $reminder = Event->timer(
> at => $time,
> cb => \&msg,
> data => 'World',
> );
What me confused at first when reading perldoc Event was that a function
takes a hash as parameter. But now I found out that this is just a list
interpreted as a hash. So, I'm fine again.
> sub msg {
> my $event = $_[0];
> my $text = $event->w->data;
> print "Hello $text!";
> }
>
Thanx a lot to you again, Garry.
cu Marc
------------------------------
Date: Tue, 30 Jan 2001 20:38:46 GMT
From: Henrik Thostrup Jensen <Yazum@Hotmail.com>
Subject: Re: Finding a char in string.. OMG
Message-Id: <jf9e7tc0qs1bkp62lcfjdr9so8u17nthu6@4ax.com>
On Sat, 27 Jan 2001 16:21:15 GMT, Henrik Thostrup Jensen
<Yazum@Hotmail.com> wrote:
>I've browsed through most of the perl cd bookshelf, without finding a
>prober solution of my problem
>
>I've need to find a certain char (";") in a string and remove all that
>is after the char. The only way i've been able to do this so far is by
>making the string into an array, searching through the array for the
>char and thereafter splitting the string at the char location.
>
>There have to be an easier way
>
>And yes, i am a newbie with perl
OMG!
And i was afaird no one would answer my question..
Thanks for the replies.. apparently i've been starting a conversation.
But the funny part is that i don't understand it :).. oh well carry on
(btw, it didn't really matter if the semicolon was there, just that
part of the string wasn't :))
once again.. thanks
------------------------------
Date: Tue, 30 Jan 2001 20:43:40 GMT
From: Henrik Thostrup Jensen <Yazum@Hotmail.com>
Subject: Re: Finding a char in string.. OMG
Message-Id: <7v9e7tg9f5j4r3h4cao304poad3nfickt9@4ax.com>
How to not make a follow up!
By Me, to me, from me
------------------------------
Date: Tue, 30 Jan 2001 19:22:50 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Finding a char in string
Message-Id: <95749u$j4m$1@nnrp1.deja.com>
In article <m3hf2gaou1.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> amonotod <amonotod@netscape.net> writes:
> > $string = substr ($string, 0, index ($string, ";"));
> > to this:
> > $string = substr ($string, 0, index ($string, ";") + 1);
> >
> No, adding 1 will not help. The problem is that index returns -1
> whenever the substring is not matched, and substr will leave 1
> character off the end of the string in such cases. Adding 1 will
> drop the entire string.
>
> See
>
> % perldoc -f index
> % perldoc -f substr
>
> for details.
>
> FWIW, Godzilla's original post offers a choice of methods, depending
> on whether or not ";" is needed in the result.
Yes, my point is that if you are index()ing on a semicolon which you do
not want to keep, and $string does not contain a semi colon, the
given substring() statement will lop off the trailing character. Adding
the index()+1 prevents the character loss, but also keeps the semicolon,
regardless of whether or not you want it.
> Using a regexp for
> this is yet another choice, and is arguably more robust for the
> reasons you pointed out.
<snip>
> AFAICT, there isn't any significant performance/memory difference
> between these two, under any reasonable conditions.
<snip>
> However, benchmarking these expressions to determine which is
> "better" strikes me as being penny-wise, yet pound-foolish. IMHO,
> this type of argument is all too common in clp.misc.
I completely agree, I just did it to satisfy the discussion between
Jason and moronzilla.
> btw- this is a comp.* group. ad hominem shit (both pro and con)
> is unwelcome here, as it is just more noise that almost
> always drowns out the signal.
I always leave moronzilla's sig intact; add it to your kill file. I
also always leave my own sig intact; add it to your killfile as well if
you like.
> Joe Schaefer
What was that *plonk* sound?
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 30 Jan 2001 19:25:28 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: HELP Read from file on different server?
Message-Id: <slrn97e57v.q08.efflandt@efflandt.xnet.com>
On Tue, 30 Jan 2001 10:55:38 GMT, emelin@my-deja.com <emelin@my-deja.com> wrote:
>I have a csv file on one of my homepages, and want to read the data
>from it and write to another csv file on my other homepage on a
>different server. But it only seems to work if the source file is on
>the same server as the target file?
>
>Is it possible to read data from a file on a different server?
Yes. If it is accessible with a URL something like the LWP module or
IO::Socket (see webget example in 'perldoc perlipc'). Or you could use
Net::FTP from the libnet module package.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 30 Jan 2001 20:56:40 GMT
From: napofrog@my-deja.com
Subject: Re: help! Capturing matched content in regex (with double-byte chars)
Message-Id: <9579q2$opg$1@nnrp1.deja.com>
In article <u9k87li8xm.fsf@wcl-l.bham.ac.uk>,
nobull@mail.com wrote:
> Roger Levy <rog@clandestino.stanford.edu> writes:
>
> > while (s/($my_regex)/$j/g) {
> > $myhash{$j} = $1;
> > }
>
> > the substitution always matches in the right places, but $1 is
always empty.
>
> Read about the semantics of the s///g operator used in a scalar
> context in perldoc perlop.
>
> I suspect you read about the semantics of m//g in a scalar context and
> then tried to infer the semantics of s///g. This doesn't work.
>
> You can use the s///g itself as the looping construct.
>
> s/($my_regex)/$myhash{$j} = $1; $j/eg;
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
>
Thanks--this is a nice bit of syntax to know.
By the way: _why_ do m// and s/// have different semantics for the /g
modifier? This seems like an unnecessary idiosyncracy. Is there any
reason why s///g couldn't possibly be given the looping semantics of
m//g?
Roger
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 30 Jan 2001 20:14:30 -0000
From: "Terry" <dcs@ntlworld.com>
Subject: Re: how do I temporarily close part of my site?
Message-Id: <RgFd6.10355$YT3.262059@news6-win.server.ntlworld.com>
Great stuff
Thanks for the help
TM
Brent Dax <brentdax1_@_earthlink.net> wrote in message
news:4TAd6.32414$J21.126761@newsread1.prod.itd.earthlink.net...
> "Terry" <dcs@ntlworld.com> wrote in message
> news:pvmd6.6940$cD2.232555@news2-win.server.ntlworld.com...
> > Hi,
> >
> > There will be times when I will need to modify cgi scripts, member
stats
> > etc. on my site.
> > I know that I can change the .htaccess file to deny access to these
areas
> > (and this is what my host suggests I do). My problem with this is:
> wouldn't
> > that run the risk of corrupting my files if a user's input was modifying
a
> > file or files at the time?
> >
> > If I'm wrong you can cut me off there.
> > Assuming I'm correct, I was going to upload a small text file with only
> the
> > word open or closed in it, then have my scripts first check this file
> before
> > performing their normal tasks (or not, if it was "closed"). But I would
> > still need to check that no sensitive files were open at the time, so
> would
> > have to go through a series of opening and "flocking" these files before
> > shutting off access.
> > Now, eventually, to my main problem.
> > As new users join my site they generate new member files, so I have no
way
> > of knowing the names of the files to flock.
> >
> > Is there someway I can get a listing of these files and use that list
for
> > the opening and "flocking"?
> >
> > I don't know the command (if there is one) so I'll call it "dir" to
show
> > what I want
> >
> > chomp (my @filelist = <"dir: /members/*.*">); #to get list of
> files.
>
> opendir(MEMBERS, "./members/");
> my @filelist=sort readdir(MEMBERS); #you may not need sort, but theyll
> come out in a weird order unless you use it
> closedir(MEMBERS);
>
> # if you need to select only certain files (like "*.member") do it like:
> # @filelist=glob "./members/your-stuff-with-wildcards.here";
>
> > for ($i=0; $i<=$#filelist) {
> for($i=0; $i<@filelist; ++$i) { #otherwise you get an infinite
> loop
> > $thisfile = $filelist[$i];
> > $filename = "filenumber".$i; #give each file a
unique
> > name.
> > $filepath = "/members/".$thisfile;
> $filepath="./members/".$thisfile
> > open ($filename, $filepath);
> > flock $filename;
> > }
> > open (CHK, "checkfile.txt");
> > truncate (CHK, 0);
> > print CHK, "closed\n";
> > close (CHK);
> > for ($i=0; $i<=$#filelist) {
> > $filename = "filenumber".$i; #get each unique name.
> > close ($filenum);
> > }
>
> Note the large number of changes from "/members/" to "./members/". Unless
> you have a folder off root called /members/, that whole thing would fail.
> (By putting /members/ in, you're saying that there's a folder in the same
> directory as /dev/, /etc/, and /usr/, among other directories. To see if
> this is true, type "ls /members" at your command prompt. I doubt it is.)
>
> HTH,
> --Brent Dax
> brentdax1@earthlink.net
>
>
------------------------------
Date: Tue, 30 Jan 2001 16:33:30 -0500
From: "Rob Yale" <rob@mcclear.com>
Subject: io_multihomed.t fails with make test
Message-Id: <NqGd6.124874$Z2.1576311@nnrp1.uunet.ca>
Hi,
I'm trying to build perl 5.60 on RedHat 7.0, and everything seems to go
swimmingly, until I do the 'make test'. There is one test failure:
io_multihomed.t returns that 'operation now in progress at
lib/io_multihomed.t line 108 test 6 failed.
Any thoughts on how to resolve this?
Thanks,
Rob Yale
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V10 Issue 177
**************************************