[30725] in Perl-Users-Digest
Perl-Users Digest, Issue: 1970 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 7 21:09:44 2008
Date: Fri, 7 Nov 2008 18:09:10 -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 Fri, 7 Nov 2008 Volume: 11 Number: 1970
Today's topics:
Re: determine when to change to or from daylight saving <jurgenex@hotmail.com>
Re: determine when to change to or from daylight saving <nospam-abuse@ilyaz.org>
Re: determine when to change to or from daylight saving <r.ted.byers@gmail.com>
Re: fastest way to monitor a dir <peter@makholm.net>
Re: fastest way to monitor a dir <jurgenex@hotmail.com>
Re: fastest way to monitor a dir <tim@burlyhost.com>
Re: fastest way to monitor a dir perl.code@ny.com
Re: Help: How can I parse this properties file? <tzz@lifelogs.com>
Re: How to get the memory address of a Perl variable in <u8526505@gmail.com>
Re: Is it possible to store an SV in C pointer <u8526505@gmail.com>
Re: python feature in perl? wbosse@metzler.com
Re: Should sophisticated Regexp solutions be pay as you <tzz@lifelogs.com>
Re: Should sophisticated Regexp solutions be pay as you <wahab-mail@gmx.de>
Re: Should sophisticated Regexp solutions be pay as you <tadmc@seesig.invalid>
Re: Should sophisticated Regexp solutions be pay as you <tim@burlyhost.com>
Re: SUBSTR() with replacement or lvalue performance iss <smallpond@juno.com>
Re: SUBSTR() with replacement or lvalue performance iss <wahab-mail@gmx.de>
Re: SUBSTR() with replacement or lvalue performance iss xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 07 Nov 2008 06:55:40 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <7fl8h45m9g9aq3l9fd29bn3iraoo9j45o2@4ax.com>
"Peter Wyzl" <placebo@petergreen.id.au> wrote:
>Yes but is there some 'authorative source' of what all the different
>timezones are and the daylight times for those zones and when they switch
>back and forth?
Impossible. If it were by country then at least you would have a chance.
But there are so many special rules and exceptions, in particular in the
US where even individual counties deviate from their state, not to
mention indian reservations that do or do not, etc, etc. It's just plain
a mess.
jue
------------------------------
Date: Fri, 7 Nov 2008 19:30:32 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <gf250o$1bnc$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Peter Wyzl
<placebo@petergreen.id.au>], who wrote in article <N3UQk.11775$sc2.8565@news-server.bigpond.net.au>:
> >> What you suggest is applicable to various tasks on my own machine, but
> >> actually I already have that working already. My problem involves
> >> converting times that apply to one institution on the other side of
> >> the planet into timezones that are on the other side of this
> >> continent. I don't see how working wih my own local time helps.
> >
> > Huh? Just put a different timezone string in $ENV{TZ}, right?
>
> Yes but is there some 'authorative source' of what all the different
> timezones are and the daylight times for those zones and when they switch
> back and forth?
As I said, your kernel/CRTL should already contain such a database. I
would try to follow links starting with
man tzset
to find a way to query the names of the zones...
Hope this helps,
Ilya
------------------------------
Date: Fri, 7 Nov 2008 16:08:20 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <3e36c274-4e52-44ce-90ea-6695e5c93def@t18g2000prt.googlegroups.com>
On Nov 7, 6:26=A0am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Peter Wyzl schreef:
>
> > but is there some 'authorative source' of what all the different
> > timezones are and the daylight times for those zones and when they
> > switch back and forth?
>
> I use DateTime::TimeZone which uses Olson. Good enough for me.http://sear=
ch.cpan.org/search?query=3Dtimezone&mode=3Dmodule
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."
I have downloaded the Olson timezone data, and executed the script
"parse-olson.pl". It created a directory called lib that contains the
timezone data transformed into *.pm files in a number of directories.
I have perl installed in C:\Perl. Do I just copy the files and
folders created by parse_olson.pl into C:\Perl\site, over-writing
what's already there?
Thanks
Ted
------------------------------
Date: Fri, 07 Nov 2008 15:26:35 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: fastest way to monitor a dir
Message-Id: <87prl7bois.fsf@vps1.hacking.dk>
perl.coder@ny.com writes:
> So my question is, what is the fastest way to check whether
> a new file has arrived in a directory. The new file name
> will always have a fixed prefix, with a changing suffix
> every time (usually timestamp).
The only portable solution is just to reread the entire directory as
often as needed. Some operation systems have more effective ways to
monitor the filesystem.
On Linux you can use either Linux::Inotify or Linux::Inotify2 (I don't
know the difference) on other unixy system Sys::Gamin seems to be a
possibility. This is based on Gnome's File Alteration Monitor Gamin,
which implements a generic monitor but uses more effective solutions
if available (like inotify on linux).
//Makholm
------------------------------
Date: Fri, 07 Nov 2008 07:17:04 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: fastest way to monitor a dir
Message-Id: <6tm8h41r8rergs7j2099g8jdm9ue2e6ok3@4ax.com>
perl.coder@ny.com wrote:
>So my question is, what is the fastest way to check whether
>a new file has arrived in a directory. The new file name
That totally and completely depends upon what features your OS offers
for monitoring directories.
jue
------------------------------
Date: Fri, 07 Nov 2008 10:09:03 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: fastest way to monitor a dir
Message-Id: <lv%Qk.203$5u1.10@newsfe01.iad>
perl.coder@ny.com wrote:
> So my question is, what is the fastest way to check whether
> a new file has arrived in a directory. The new file name
> will always have a fixed prefix, with a changing suffix
> every time (usually timestamp).
What operating system are you using this for? That will probably
determine the best solution over another.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: 7 Nov 2008 10:20:17 -0800
From: perl.code@ny.com
Subject: Re: fastest way to monitor a dir
Message-Id: <gf20t1026eq@drn.newsguy.com>
In article <lv%Qk.203$5u1.10@newsfe01.iad>, Tim Greer says...
>
>perl.coder@ny.com wrote:
>
>> So my question is, what is the fastest way to check whether
>> a new file has arrived in a directory. The new file name
>> will always have a fixed prefix, with a changing suffix
>> every time (usually timestamp).
>
>What operating system are you using this for? That will probably
>determine the best solution over another.
Solaris
AIX
Linux
thanks all for the replies.
------------------------------
Date: Fri, 07 Nov 2008 08:39:09 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Help: How can I parse this properties file?
Message-Id: <863ai3ppma.fsf@lifelogs.com>
On Thu, 06 Nov 2008 14:39:37 +0100 Michele Dondi <bik.mido@tiscalinet.it> wrote:
MD> On Wed, 05 Nov 2008 11:28:24 -0600, Ted Zlatanov <tzz@lifelogs.com>
MD> wrote:
TJM> $line =~ s/\\\\/&backslash;/g; # translate literal backslashes
>>
TJM> my($key, $value) = split /(?<!\\)=/, $line, 2; # use negative look-behind
>>
TJM> $key =~ tr/\\//d; # eliminate backslashes used for escaping
>>
TJM> $key =~ s/&backslash;/\\/g; # put the literal backslashes back in
>>
TJM> printf "%-10s %-10s\n", $key, $value;
TJM> }
>>
TJM> __DATA__
TJM> a=b=c
TJM> a\=b=c
TJM> a\\=b=c
TJM> a\\\=b=c
TJM> ----------------------------
>>
>> I was thinking of a similar solution, but adding 256 (or some other
>> large number) to each escaped character (in case there's a '&backslash;'
>> in the data). As long as it's valid Unicode and the original data
>> doesn't contain Unicode characters it should be a clean translation.
MD> I like to be sure thus instead of adding "some other large number" I
MD> actually *find* something that *can't* be there:
MD> my $delim = "&". (sort @delims = $line =~ /&(\0+);/)[-1] . "\0;";
MD> $line =~ s/\\\\/$delim;/g; # translate literal backslashes
MD> # ...
Surely there's a CPAN module to do this... Or 10...
From the docs of Encode::Escape, there's also String::Escape,
Unicode::Escape, TeX::Encode, HTML::Mason::Escape,
Template::Plugin::XML::Escape, URI::Escape.
Ted
------------------------------
Date: Fri, 7 Nov 2008 14:57:26 -0800 (PST)
From: cyl <u8526505@gmail.com>
Subject: Re: How to get the memory address of a Perl variable in XS
Message-Id: <5e9bb795-fcc6-45ec-afdc-07c6e12821e6@a3g2000prm.googlegroups.com>
On 11$B7n(B3$BF|(B, $B2<8a(B8$B;~(B36$BJ,(B, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> cyl <u8526...@gmail.com> writes:
>
> > How do I get the memory address of \@arr in xs_test?
>
> void* address = (void*) sv;
>
> > Will the content in that address change when exiting the xs_test
> > function? Thanks.
>
> That's always possible, but you probably should at least increment the
> refcount on sv if you're planning on keeping it around.
>
> --
> Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
I use newSVsv to clone a copy of that SV and it works now. I think the
problem is because the SV I want to save is on the stack and is
collected when exiting my function call.
------------------------------
Date: Fri, 7 Nov 2008 14:51:25 -0800 (PST)
From: cyl <u8526505@gmail.com>
Subject: Re: Is it possible to store an SV in C pointer
Message-Id: <4d38192a-4ef6-4b95-83b6-9902bddb2fe0@b31g2000prb.googlegroups.com>
On 10$B7n(B24$BF|(B, $B>e8a(B9$B;~(B04$BJ,(B, cyl <u8526...@gmail.com> wrote:
> On 10$B7n(B24$BF|(B, $B>e8a(B6$B;~(B22$BJ,(B, Leon Timmermans <faw...@gmail.com> wrote:> > my $ref = [1,2,3];
>
> > > funcA($ref);
> > > funcB(); # which uses the pointer p to access $ref
> > > __END__
>
> > The address doesn't change. The address you have is $ref. Though I'm
> > wondering why you would store it in a void* when you can store it in a
> > SV*.
>
> But the value is changed when I access the address in funcB. In funcA,
I think my problem is that the SV I want to save is from ST(0) where
the address is on the stack and the value is getting changed
frequently. After cloning a copy of that SV by newSVsv, I have no
problem now. I'm not sure if it works to increase the reference count
of a SV on the stack.
------------------------------
Date: Fri, 7 Nov 2008 06:35:33 -0800 (PST)
From: wbosse@metzler.com
Subject: Re: python feature in perl?
Message-Id: <17ec6d5f-c72f-4954-9568-2dbfe5ec42b8@q26g2000prq.googlegroups.com>
Mike schrieb:
> I like that in python you can say:
>
> if __name__ == "__main__"
unless ( caller() ) {
> tests
}
>
> To know if you are running a $module.py file stand alone or if the
> $module.py file has been included into a different, super python
> script. Is there a similar feature in PERL? I've been using PERL
> for a long time and I don't remember anything like this. I can think
> of a way to emulate the feature, but I prefer to have a built in
> instead of an emulation hack.
>
> Mike
------------------------------
Date: Fri, 07 Nov 2008 08:35:43 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Should sophisticated Regexp solutions be pay as you go requested?
Message-Id: <867i7fpps0.fsf@lifelogs.com>
On Fri, 07 Nov 2008 10:15:25 GMT sln@netherlands.com wrote:
s> I've noticed alot of complex regular expression problems posted here
s> that require alot of thought.
s> Should there be monetary compensation for such complex solutions?
No.
Ted
------------------------------
Date: Fri, 07 Nov 2008 16:53:14 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Should sophisticated Regexp solutions be pay as you go requested?
Message-Id: <gf1odl$pg7$1@mlucom4.urz.uni-halle.de>
sln@netherlands.com wrote:
> I've noticed alot of complex regular expression problems posted here that require
> alot of thought.
>
> Should there be monetary compensation for such complex solutions?
No, we're getting older and the topic has
enough payback in itself,
eg.: http://www.medicinenet.com/script/main/art.asp?articlekey=23705
Regards
M.
------------------------------
Date: Fri, 7 Nov 2008 09:03:23 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Should sophisticated Regexp solutions be pay as you go requested?
Message-Id: <slrngh8m5r.h7d.tadmc@tadmc30.sbcglobal.net>
sln@netherlands.com <sln@netherlands.com> wrote:
> I've noticed alot of complex regular expression problems
> posted here that require
^^^^^^^^^^^
^^^^^^^^^^^
> alot of thought.
>
> Should there be monetary compensation for such complex solutions?
No. That would violate the non-commercial nature of Usenet.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 07 Nov 2008 10:06:17 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Should sophisticated Regexp solutions be pay as you go requested?
Message-Id: <ts%Qk.201$5u1.86@newsfe01.iad>
sln@netherlands.com wrote:
> I've noticed alot of complex regular expression problems posted here
> that require alot of thought.
>
> Should there be monetary compensation for such complex solutions?
>
> sln
Nope. No one's obligated to reply or spend the time if they don't wish
to. So, no harm, no foul. Besides, it can be interesting and open you
up to new things you've not considered before, or even learn something
yourself in the process of helping others.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 7 Nov 2008 08:00:59 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <f628b485-488b-486e-b2a9-7bb2de67630e@35g2000pry.googlegroups.com>
On Nov 7, 12:48 am, s...@netherlands.com wrote:
>
> I'm looking over you benches. I have a bad feeling though. Insertion
> (or deletion) several hundred thousand possible times could reek havoc
> maybe.
>
code can reek, but havoc must be wreaked.
It is good practice to see if you actually have a problem before doing
optimization. "First make it right, then make it fast."
------------------------------
Date: Fri, 07 Nov 2008 17:21:16 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <gf1q27$q1k$1@mlucom4.urz.uni-halle.de>
sln@netherlands.com wrote:
> Yes. I'm looking at your benchmarks for substr(). I have nightmares on
> if threre are like over 100,000 replacements in a gigantic string which
> could easily happen. There is a block replacement, I'm not doing s///g
> on a gigantic string. I'm finding a block, then acting on indirect values,
> then re-inserting them in the stream. Regexp has stopped, to be re'pos()
> later (or not). Depends on if a seperate file is being constructed or
> the replacement is acting strictly on the buffer.
What is the problem domain? "Megabyte strings" and
"100,000 things" to might not turn out that slow on
a usual 3GHz Core2 that has 6MB L2 available.
> I'm looking over you benches. I have a bad feeling though. Insertion
> (or deletion) several hundred thousand possible times could reek havoc
> maybe.
A 'left value'-substr() might be beaten by an
"Inline C" based use of memchr/memcpy - that
unfortunately would need to handle the reallocation
of the buffer manually (if possible/feasible at
all in your problem range).
Regards
M.
------------------------------
Date: 07 Nov 2008 17:49:21 GMT
From: xhoster@gmail.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <20081107124955.499$hb@newsreader.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Fri, 07 Nov 2008 02:17:58 GMT, sln@netherlands.com wrote:
>
> >Apart from like, copy from the start of a matched position, to a
> >file (as opposed to another buffer), then catenating the modification
> >to the file, then continue on with the next match, is the substr
> >(lvalue or replacement) a viable option?
> >
> >I have to consider performance on such large operations.
>
> ISTR that the lvaluedness of substr()'s return value, as long as the
> fact that you can EVEN take references of it and modify the string
> with a sort of action-at-distance was put there specifically for
> performance issues. At some point there were problems with
> substitutions having a lenght larger than the substituted IalsoIRC,
> but they should be solved in recent enough perls.
>
> See: <http://perlmonks.org/?node_id=498434>
My reading of that is there used to be problems having more than one
action-at-distance references outstanding on the same string, regardless
of the size of the replacements.
Doing replacements that don't preserve length can have a performance
impact, but I don't see that as a "problem" in the same way a bug is a
"problem"; just as one of the trade-offs that always exist and which need
to be kept in mind. I doubt this performance issue will be "fixed" anytime
soon, as it would likely require a fundamental change of the way strings
are managed (i.e. as ropes rather than as contiguous memory regions.)
Of course, the other issue is one of semantics. If I take reference like
my $x=\substr($q,100,10), and then later do an insertion like
substr($q,10,0,"xxx"), will $x now refer to the same *characters* as it did
before (i.e. substr($q,103,10)) or to the same *positions* as it did
before. Empirically, it refers to the same positions.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
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 1970
***************************************