[30726] in Perl-Users-Digest
Perl-Users Digest, Issue: 1971 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 8 09:09:44 2008
Date: Sat, 8 Nov 2008 06:09:07 -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 Sat, 8 Nov 2008 Volume: 11 Number: 1971
Today's topics:
Re: determine when to change to or from daylight saving <placebo@petergreen.id.au>
Re: determine when to change to or from daylight saving <nospam-abuse@ilyaz.org>
Re: determine when to change to or from daylight saving <mgjv@heliotrope.com.au>
Re: Envirnoment (?) question [LONG] <whynot@pozharski.name>
Re: Help: How can I parse this properties file? <yuanyun.ken@gmail.com>
Re: Help: How can I parse this properties file? <tadmc@seesig.invalid>
Re: Help: How can I parse this properties file? <jurgenex@hotmail.com>
Re: Help: How can I parse this properties file? (fB)
new CPAN modules on Sat Nov 8 2008 (Randal Schwartz)
Re: perl maximum memory <hjp-usenet2@hjp.at>
Re: python feature in perl? <whynot@pozharski.name>
Re: python feature in perl? (fB)
Re: Question on the length of a Scalar <hjp-usenet2@hjp.at>
Re: Question on the length of a Scalar <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 07 Nov 2008 23:19:48 GMT
From: "Peter Wyzl" <placebo@petergreen.id.au>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <o24Rk.12858$sc2.2859@news-server.bigpond.net.au>
"Ilya Zakharevich" <nospam-abuse@ilyaz.org> wrote in message
news:gf250o$1bnc$1@agate.berkeley.edu...
> [A complimentary Cc of this posting was sent to
> Peter Wyzl
>>
>> 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...
If I wasn't one of the large % of users who don't have a kernel as such,
that might be helpful.
P
------------------------------
Date: Sat, 8 Nov 2008 09:09:29 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <gf3l09$1r3r$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Peter Wyzl
<placebo@petergreen.id.au>], who wrote in article <o24Rk.12858$sc2.2859@news-server.bigpond.net.au>:
> If I wasn't one of the large % of users who don't have a kernel as such,
And who do you think runs your Perl? Maybe the BIOS? ;-)
Anyway, POSIX::tzset will run tzset() function of the CRTL of (your?)
compiler. Its documentation may also contain a list...
(But probably tzset() is very crippled on Win*...)
Yours,
Ilya
------------------------------
Date: Sat, 8 Nov 2008 21:13:54 +1100
From: Martien Verbruggen <mgjv@heliotrope.com.au>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <slrnghapj2.jqo.mgjv@mgjv.heliotrope.home>
On Sat, 8 Nov 2008 09:09:29 +0000 (UTC),
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> Peter Wyzl
><placebo@petergreen.id.au>], who wrote in article
><o24Rk.12858$sc2.2859@news-server.bigpond.net.au>:
>
>> If I wasn't one of the large % of users who don't have a kernel as such,
>
> And who do you think runs your Perl? Maybe the BIOS? ;-)
>
> Anyway, POSIX::tzset will run tzset() function of the CRTL of (your?)
> compiler. Its documentation may also contain a list...
THis is the second time you've used the (presumably) acronym CRTL. What
exactly do you mean by that? I don't know the term, and Google,
Wikipedia freedictionary and the hacker's dictionary also don't seem to
help.
Martien
--
|
Martien Verbruggen | Make it idiot proof and someone will make a
| better idiot.
|
------------------------------
Date: Sat, 08 Nov 2008 01:00:09 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Envirnoment (?) question [LONG]
Message-Id: <slrngh9i48.72q.whynot@orphan.zombinet>
On 2008-11-07, Thumain Th. <thumain.the@invalid.invalid> wrote:
> Le Fri, 07 Nov 2008 01:00:44 +0100, Eric Pozharski <whynot@pozharski.name>
> a écrit:
>
>> On 2008-11-06, Thumain Th. <thumain.the@invalid.invalid> wrote:
>> *SKIP*
>>
> Thanks for your answer , s
>
>>> On one of our systems XMLin
>>
>> Please explain difference between 'one of' and 'our systems'.
>>
> Excellent question!
> Same file and program runs OK on all our systems but not on THIS one.
> THIS system is Suse 9.3 , perl 5.8.6 and old 5.000503 leaves
> in/usr/local/lib/perl5/... , development
> environment was migrated to this machine , perl 5.8.6 was installed and
> many modules (including XML , ...)
> were just copied from original /usr/local/lib/perl5/5.0000503 to same
> directories (ie NOT 5.8.6) on this
> system. They seem to function OK.
Oh, no... I think, you are on your own with such a mess. I (strongly)
advice to clean up and reinstall the whole environment the right way. I
haven't personal experience with mixed environments, but that's surely
doable. Post here for advice. Look, you can't "just copy", you must
*install*. You are free to go your way, but consider changing it.
> Other systems are RH 7.2/perl 5.000503 ,RH 6 and other linux flavors.
>
> One of our customers runs same system as THIS and program and file run OK
> on it...
>
>>> crashes with 'illecal xml character' (file.xml is OK).
>>
>> Please copy-paste exact and full messages.
>>
>> *CUT*
>>
>
>
> XML::SAX::Exception::throw('XML::SAX::Exception::Parse', 'Message',
> 'Not a v
> alid XML character: \'=\'') called at
> /usr/lib/perl5/vendor_perl/5.8.6/XML/
> SAX/PurePerl/Reader.pm line 92
> XML::SAX::PurePerl::Reader::match('XML::SAX::PurePerl::Reader::Stream=ARRAY(
> 0x890df10)', '=') called at
> /usr/lib/perl5/vendor_perl/5.8.6/XML/SAX/PurePerl/XM
> LDecl.pm line 52
If my understanding of "Extensible Markup Language (XML) 1.0 (Fourth
Edition)" (what I have on hand), section 4.1 is correct than
'&#x' [0-9a-fA-F]+ ';'
is perfectly valid B<CharRef>. C<=> fits that spec and is out of
(even) discouraged ranges of Unicode. From POV of
/usr/lib/perl5/vendor_perl/5.8.6/XML/SAX/PurePerl/Reader.pm it's not.
Point. Either reconsider your way, or look at http://rt.cpan.org for
bugreports of B<XML-SAX> distribution (that F<Reader.pm> is of it). If
you'll find nothing promising, then read F<Changes> on
L<http://cpan.org>; yes, not local (you don't know for sure of what
version local F<Changes> are). If there won't be nothing too, then
start fixing F<Reader.pm>.
Look, if you'll go that long exciting way *and* accidentally succeed,
then you'll feel yourself a kind of superman. Just keep in mind, fixing
that particular problem doesn't solve the whole mess. You would just
delay the next hit. And it's coming, I promise.
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: Fri, 7 Nov 2008 19:55:48 -0800 (PST)
From: "yuanyun.ken" <yuanyun.ken@gmail.com>
Subject: Re: Help: How can I parse this properties file?
Message-Id: <472482c3-a0b7-407a-8ba8-a9485e4ff5d6@b38g2000prf.googlegroups.com>
Thanks for all the reply. and this problem has been solved.
but sorry for my poor understanding on regex, and having to trouble
you again,
here I have another little problem:
if the content ends with a real single backslash, I need read in the
next line.
How to use regex to do this?
for example:
line ends with match
\ yes
\\ no
\\\ yes
\\\\ no
Thanks for any help again.
------------------------------
Date: Fri, 7 Nov 2008 22:15:50 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help: How can I parse this properties file?
Message-Id: <slrngha4jm.o6t.tadmc@tadmc30.sbcglobal.net>
yuanyun.ken <yuanyun.ken@gmail.com> wrote:
> Thanks for all the reply. and this problem has been solved.
> but sorry for my poor understanding on regex, and having to trouble
> you again,
> here I have another little problem:
> if the content ends with a real single backslash, I need read in the
> next line.
>
> How to use regex to do this?
> for example:
> line ends with match
> \ yes
> \\ no
> \\\ yes
> \\\\ no
-------------------
#!/usr/bin/perl
use warnings;
use strict;
foreach my $line ( <DATA> ) {
chomp $line;
if ( $line =~ /(\\+)$/ and length($1) % 2 )
{ print "yes\n" }
else
{ print "no\n" }
}
__DATA__
\
\\
\\\
\\\\
-------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 07 Nov 2008 21:26:44 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help: How can I parse this properties file?
Message-Id: <ik8ah4pkpl1qlmhiahtsk5d7p0b1eotcbp@4ax.com>
"yuanyun.ken" <yuanyun.ken@gmail.com> wrote:
>Thanks for all the reply. and this problem has been solved.
>but sorry for my poor understanding on regex, and having to trouble
>you again,
>here I have another little problem:
>if the content ends with a real single backslash, I need read in the
>next line.
>
>How to use regex to do this?
You don't. When the tokenizer discovers a backslash it just reads
another character and if that character is an EOL then just continue
processing the next line instead of reporting an end-of-token.
jue
------------------------------
Date: Sat, 8 Nov 2008 14:59:30 +0100
From: spamtrap@blameit.net (fB)
Subject: Re: Help: How can I parse this properties file?
Message-Id: <2jigu5-ve5.ln1@warehouse.blameit.net>
"yuanyun.ken" <yuanyun.ken@gmail.com> wrote in <472482c3-a0b7-407a-8ba8-a9485e4ff5d6@b38g2000prf.googlegroups.com>:
> Thanks for all the reply. and this problem has been solved.
> but sorry for my poor understanding on regex, and having to trouble
> you again,
> here I have another little problem:
> if the content ends with a real single backslash, I need read in the
> next line.
>
> How to use regex to do this?
> for example:
> line ends with match
> \ yes
> \\ no
> \\\ yes
> \\\\ no
> Thanks for any help again.
I felt like doing your homework for you, and anyway it is not that difficult.
#!/usr/bin/perl
use strict;
use warnings;
use feature ':5.10';
while (<::DATA>) {
chomp;
printf '%10s', $_;
m{ (?: [^\\] | ^ ) # match a non-backslash character
# or the start of the string
( \\ (?:\\\\)* ) # match an odd number of backslashes
$ # followed by the end of the string
}xms
and say ' matched: '.$1
or say ' not matched';
}
exit;
__DATA__
\
\\
\\\
\\\\
\\\\\
\\\\\\
\\\\\\\
\\\\\\\\
a
a\
a\\
a\\\
a\\\\
a\\\\\
a\\\\\\
a\\\\\\\
a\\\\\\\\
\a
\\a
\\\a
\\\\a
__END__
--
------------------------------
Date: Sat, 8 Nov 2008 05:42:21 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Nov 8 2008
Message-Id: <KA02IL.1LoJ@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-Tiroler-0.06
http://search.cpan.org/~marcel/Acme-Tiroler-0.06/
write code like a tyrolean says it
----
Alien-wxWidgets-0.42
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.42/
building, finding and using wxWidgets binaries
----
App-Benchmark-0.03
http://search.cpan.org/~marcel/App-Benchmark-0.03/
Output your benchmarks as test diagnostics
----
App-CPAN-Mini-Visit-v0.1.0
http://search.cpan.org/~dagolden/App-CPAN-Mini-Visit-v0.1.0/
explore each distribution in a minicpan repository
----
App-ZofCMS-Plugin-Comments-0.0102
http://search.cpan.org/~zoffix/App-ZofCMS-Plugin-Comments-0.0102/
drop-in visitor comments support.
----
App-ZofCMS-Plugin-Debug-Validator-HTML-0.0102
http://search.cpan.org/~zoffix/App-ZofCMS-Plugin-Debug-Validator-HTML-0.0102/
debugging plugin for auto validating HTML
----
App-ZofCMS-PluginReference-0.0102
http://search.cpan.org/~zoffix/App-ZofCMS-PluginReference-0.0102/
docs for all plugins in one document for easy reference
----
Bundle-MARCEL-0.08
http://search.cpan.org/~marcel/Bundle-MARCEL-0.08/
install (nearly) all modules by MARCEL
----
CGI-IDS-1.0102
http://search.cpan.org/~hinnerk/CGI-IDS-1.0102/
PerlIDS - Perl Website Intrusion Detection System (XSS, CSRF, SQLI, LFI etc.)
----
CatalystX-CRUD-Model-RDBO-0.15
http://search.cpan.org/~karman/CatalystX-CRUD-Model-RDBO-0.15/
Rose::DB::Object CRUD
----
Class-Accessor-Complex-0.15
http://search.cpan.org/~marcel/Class-Accessor-Complex-0.15/
arrays, hashes, booleans, integers, sets and more
----
Class-MOP-0.69
http://search.cpan.org/~drolsky/Class-MOP-0.69/
A Meta Object Protocol for Perl 5
----
Class-Null-1.10
http://search.cpan.org/~marcel/Class-Null-1.10/
Implements the Null Class design pattern
----
Config-Multi-0.06
http://search.cpan.org/~taro/Config-Multi-0.06/
load multiple config files.
----
DBIx-Class-Stash-0.05
http://search.cpan.org/~nekokak/DBIx-Class-Stash-0.05/
stash for DBIC
----
Daemon-Easy-0.01
http://search.cpan.org/~jzhang/Daemon-Easy-0.01/
easily create a daemon
----
Dynamic-Loader-1.07
http://search.cpan.org/~alexmass/Dynamic-Loader-1.07/
call a script without to know where is his location.
----
Fey-DBIManager-0.08
http://search.cpan.org/~drolsky/Fey-DBIManager-0.08/
Manage a set of DBI handles
----
Fey-ORM-0.12
http://search.cpan.org/~drolsky/Fey-ORM-0.12/
A Fey-based ORM
----
Form-Processor-Model-RDBO-0.001
http://search.cpan.org/~dzhariy/Form-Processor-Model-RDBO-0.001/
Model class for Form Processor using Rose::DB::Object
----
Form-Processor-Model-RDBO-0.01
http://search.cpan.org/~dzhariy/Form-Processor-Model-RDBO-0.01/
Model class for Form Processor using Rose::DB::Object
----
GD-Chord-Piano-0.0.3
http://search.cpan.org/~bayashi/GD-Chord-Piano-0.0.3/
Generate Chord Table of Piano
----
Geo-OSM-MapFeatures-0.02
http://search.cpan.org/~bobkare/Geo-OSM-MapFeatures-0.02/
Parses and represents OpenStreetMap Map Features
----
HTML-Tested-0.45
http://search.cpan.org/~bosu/HTML-Tested-0.45/
Provides HTML widgets with the built-in means of testing.
----
HTTP-MobileAgent-Flash-0.06
http://search.cpan.org/~takefumi/HTTP-MobileAgent-Flash-0.06/
Flash information for HTTP::MobileAgent
----
HTTP-Session-0.09
http://search.cpan.org/~tokuhirom/HTTP-Session-0.09/
simple session
----
IO-Lambda-0.38
http://search.cpan.org/~karasik/IO-Lambda-0.38/
non-blocking I/O in lambda style
----
Lexical-Persistence-0.98
http://search.cpan.org/~rcaputo/Lexical-Persistence-0.98/
Persistent lexical variable values for arbitrary calls.
----
Log-Dump-0.01
http://search.cpan.org/~ishigaki/Log-Dump-0.01/
simple logger mainly for debugging
----
Module-Release-2.00_07
http://search.cpan.org/~bdfoy/Module-Release-2.00_07/
Automate software releases
----
Module-Util-1.05
http://search.cpan.org/~mattlaw/Module-Util-1.05/
Module name tools and transformations
----
Mojo-0.8007
http://search.cpan.org/~sri/Mojo-0.8007/
The Web In A Box!
----
Mojo-0.8008
http://search.cpan.org/~sri/Mojo-0.8008/
The Web In A Box!
----
Moose-0.61
http://search.cpan.org/~drolsky/Moose-0.61/
A postmodern object system for Perl 5
----
Moxy-0.49_01
http://search.cpan.org/~tokuhirom/Moxy-0.49_01/
Mobile web development proxy
----
Net-Whois-Raw-1.58
http://search.cpan.org/~despair/Net-Whois-Raw-1.58/
Get Whois information for domains
----
Nmap-Parser-1.19
http://search.cpan.org/~apersaud/Nmap-Parser-1.19/
parse nmap scan data with perl
----
Padre-Plugin-PluginHelper-0.06
http://search.cpan.org/~fayland/Padre-Plugin-PluginHelper-0.06/
make building Padre plugin easy
----
Padre-Plugin-PluginHelper-0.07
http://search.cpan.org/~fayland/Padre-Plugin-PluginHelper-0.07/
make building Padre plugin easy
----
Padre-Plugin-PluginHelper-0.08
http://search.cpan.org/~fayland/Padre-Plugin-PluginHelper-0.08/
make building Padre plugin easy
----
Parse-GEDA-Gschem-v1.00
http://search.cpan.org/~jpfricker/Parse-GEDA-Gschem-v1.00/
----
Parse-RPN-2.43
http://search.cpan.org/~fdulau/Parse-RPN-2.43/
----
Path-Abstract-0.094_1
http://search.cpan.org/~rkrimen/Path-Abstract-0.094_1/
Fast and featureful UNIX-style path manipulation
----
Rose-DBx-Object-I18N-0.01
http://search.cpan.org/~vti/Rose-DBx-Object-I18N-0.01/
set of modules to deal with multilingual database
----
Rose-DBx-Object-I18N-0.02
http://search.cpan.org/~vti/Rose-DBx-Object-I18N-0.02/
set of modules to deal with multilingual database
----
String-BufferStack-1.00
http://search.cpan.org/~alexmv/String-BufferStack-1.00/
Nested buffers for templating systems
----
Task-App-ZofCMS-0.0104
http://search.cpan.org/~zoffix/Task-App-ZofCMS-0.0104/
bundle of ZofCMS core and all of its plugins
----
Task-Padre-Plugins-0.01
http://search.cpan.org/~szabgab/Task-Padre-Plugins-0.01/
Get many Plugins of Padre at once
----
Text-Chord-Piano-0.0.2
http://search.cpan.org/~bayashi/Text-Chord-Piano-0.0.2/
This module is a chord table generator of Piano by the text
----
WWW-Contact-0.17
http://search.cpan.org/~fayland/WWW-Contact-0.17/
Get contacts/addressbook from Web
----
WWW-MobileCarrierJP-0.22
http://search.cpan.org/~tokuhirom/WWW-MobileCarrierJP-0.22/
scrape mobile carrier information
----
WWW-MobileCarrierJP-0.23
http://search.cpan.org/~tokuhirom/WWW-MobileCarrierJP-0.23/
scrape mobile carrier information
----
WWW-Search-HGNC-0.03
http://search.cpan.org/~diberri/WWW-Search-HGNC-0.03/
Access HGNC's database of proteins
----
WebService-Nestoria-Search-1.14.1
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-1.14.1/
Perl interface to the Nestoria Search public API.
----
WebService-Nestoria-Search-1.14.1-2
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-1.14.1-2/
Perl interface to the Nestoria Search public API.
----
WebService-Nestoria-Search-1.14.1-3
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-1.14.1-3/
Perl interface to the Nestoria Search public API.
----
Wx-0.87
http://search.cpan.org/~mbarbon/Wx-0.87/
interface to the wxWidgets cross-platform GUI toolkit
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sat, 8 Nov 2008 13:36:44 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl maximum memory
Message-Id: <slrnghb1ut.chg.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-05 21:13, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
><hjp-usenet2@hjp.at>], who wrote in article <slrngh39kn.819.hjp-usenet2@hrunkner.hjp.at>:
>> For 64-bit processes the limit is theoretically 16 Exabytes, but that's
>> well beyond the capabilities of current hardware.
>
> ??? Well *within* capabilities of current hardware. One ethernet
> card, and you have *a possibility* of unlimited (read: limited only by
> software) expansion of available disk space; which may be
> memory-mapped.
Last time I looked there was no processor which would actually use all
64 bits in the MMU. The usable number of bits is typically somewhere
between 36 and 48, which limits the usable virtual memory (including
memory-mapped files, etc.) to 2^36 to 2^48 bytes.
> So it is a question of money only.
If you have enough money to develop a new MMU for your CPU, you are
right ;-).
hp
------------------------------
Date: Sat, 08 Nov 2008 11:18:38 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: python feature in perl?
Message-Id: <slrnghambv.h45.whynot@orphan.zombinet>
On 2008-11-07, Mike <mikee@mikee.ath.cx> wrote:
> I like that in python you can say:
>
> if __name__ == "__main__"
> tests
die unless caller;
There can be dragons though.
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: Sat, 8 Nov 2008 14:12:50 +0100
From: spamtrap@blameit.net (fB)
Subject: Re: python feature in perl?
Message-Id: <irfgu5-l8u.ln1@warehouse.blameit.net>
Eric Pozharski <whynot@pozharski.name> wrote in <slrnghambv.h45.whynot@orphan.zombinet>:
> On 2008-11-07, Mike <mikee@mikee.ath.cx> wrote:
> > I like that in python you can say:
> >
> > if __name__ == "__main__"
> > tests
>
> die unless caller;
>
> There can be dragons though.
Depending on intended use it might be better to use __PACKAGE__ (as documented
in perlmod) rather than caller. For one, I find it easier to understand its
purpose:
if ( __PACKAGE__ eq 'main' ) {
tests;
}
or even, in case 'tests' represents a single statement:
tests if __PACKAGE__ eq 'main';
Moreover, should you need the return value from caller, you must remember to
check that you are using the correct context:
#!/usr/bin/perl
use strict;
use warnings;
use feature ':5.10';
{
package test;
sub check {
say scalar caller if caller;
return;
}
}
say scalar caller if caller;
test::check;
exit;
--
fB
------------------------------
Date: Sat, 8 Nov 2008 09:05:08 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question on the length of a Scalar
Message-Id: <slrnghai1l.2e5.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-06 06:25, Joe Smith <joe@inwap.com> wrote:
> Peter J. Holzer wrote:
>> On 2008-10-22 21:31, xhoster@gmail.com <xhoster@gmail.com> wrote:
>>> sln@netherlands.com wrote:
>>>> I just have a simple question.
>>>>
>>>> When I call the length function on a scalar, is it read directly
>>>> (ie: already know its length), or does it traverse the string
>>>> counting its characters until it hits a nul terminator?
>>> The first one.
>>
>> That depends on the string. If it is a byte string, you are right.
>
> No. A scalar string in Perl has its length stored in the typeglob
> as part of the variable's metadata.
That's the length in bytes, not the length in characters. In the case of
a byte string that's identical, but for a character string it is not (a
character may be more than one byte).
> perl
> $string = "=" x 80 . "\000" . "_" x 80 . "\000";
> die if length $string != 80+1+80+1;
> print "The string, with embedded nulls, is ", length $string, " bytes.\n";
> $string .= "\x{1234}";
> print "Adding one UTF-8 character, the length is now ", length $string, ".\n";
> ^D
> The string, with embedded nulls, is 162 bytes.
> Adding one UTF-8 character, the length is now 163.
What is this example meant to demonstrate?
>> If it is a scalar string, the string must be traversed to count the
>> characters.
Sorry for the typo. That should have read "character string", not
"scalar string".
> Nope. Perl knows exactly how many characters are in a string at all
> times.
>
>> However, the result seems to be cached
>
> There is no "seems to be" about it. The size of a scalar is stored as
> part of the typeglob where it can be accessed _without_ traversing the
> string.
Definitely not. I tested it, and the *first* time length is called on
any string, it takes linear time - which is imho a clear indication that
it does not know how many characters there are and needs to count them.
However, on subsequent calls, the result is returned immediately, so the
result of the previous call must be cached somewhere. I don't see it in
the output of Devel::Peek::Dump, so I guess it isn't stored in the SV.
hp
------------------------------
Date: Sat, 8 Nov 2008 13:53:24 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question on the length of a Scalar
Message-Id: <slrnghb2u5.cn9.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-08 08:05, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> Definitely not. I tested it, and the *first* time length is called on
> any string, it takes linear time - which is imho a clear indication that
> it does not know how many characters there are and needs to count them.
> However, on subsequent calls, the result is returned immediately, so the
> result of the previous call must be cached somewhere. I don't see it in
> the output of Devel::Peek::Dump, so I guess it isn't stored in the SV.
Correction: It is visible:
"a" x 10 . "¤":
SV = PV(0x9c3a730) at 0x9c56290
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x9cb79e8 "aaaaaaaaaa\342\202\254"\0 [UTF8 "aaaaaaaaaa\x{20ac}"]
CUR = 13
LEN = 16
Length in bytes (13) is correct. No length in characters.
After calling length wie have a "magic" field which contains the length in
characters:
SV = PVMG(0x9c857c8) at 0x9c56290
REFCNT = 1
FLAGS = (PADMY,SMG,POK,pPOK,UTF8)
IV = 0
NV = 0
PV = 0x9cb79e8 "aaaaaaaaaa\342\202\254"\0 [UTF8 "aaaaaaaaaa\x{20ac}"]
CUR = 13
LEN = 16
MAGIC = 0x9c5b278
MG_VIRTUAL = &PL_vtbl_utf8
MG_TYPE = PERL_MAGIC_utf8(w)
MG_LEN = 11
After adding another character, the magic field is still there but invalid:
V = PVMG(0x88e57c8) at 0x88b6290
REFCNT = 1
FLAGS = (PADMY,SMG,POK,pPOK,UTF8)
IV = 0
NV = 0
PV = 0x89179e8 "aaaaaaaaaa\342\202\254\342\202\254"\0 [UTF8 "aaaaaaaaaa\x{20ac}\x{20ac}"]
CUR = 16
LEN = 20
MAGIC = 0x88bb278
MG_VIRTUAL = &PL_vtbl_utf8
MG_TYPE = PERL_MAGIC_utf8(w)
MG_LEN = -1
hp
------------------------------
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 1971
***************************************