[30740] in Perl-Users-Digest
Perl-Users Digest, Issue: 1985 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 15 21:09:47 2008
Date: Sat, 15 Nov 2008 18: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 Sat, 15 Nov 2008 Volume: 11 Number: 1985
Today's topics:
Re: atoi/atof <hjp-usenet2@hjp.at>
Re: atoi/atof sln@netherlands.com
Re: BigInt in per <hjp-usenet2@hjp.at>
Re: Client-Server Communication in Perl CGI <hjp-usenet2@hjp.at>
Re: determine when to change to or from daylight saving <hjp-usenet2@hjp.at>
Re: determine when to change to or from daylight saving <hjp-usenet2@hjp.at>
Re: FAQ 6.7 How can I make "\w" match national characte <hjp-usenet2@hjp.at>
Re: HTML::Entities & UTF8 <hjp-usenet2@hjp.at>
Re: nested foreach loop sln@netherlands.com
Re: parameter error during function call <jurgenex@hotmail.com>
Re: parameter error during function call <hjp-usenet2@hjp.at>
PHP's ob_gzhandler equivalent in Perl ? <howachen@gmail.com>
Re: PHP's ob_gzhandler equivalent in Perl ? <jurgenex@hotmail.com>
Re: PHP's ob_gzhandler equivalent in Perl ? <hjp-usenet2@hjp.at>
Re: python feature in perl? <hjp-usenet2@hjp.at>
Re: python feature in perl? <news123@free.fr>
Re: Using unreferenced labels <hjp-usenet2@hjp.at>
Re: Using unreferenced labels <hjp-usenet2@hjp.at>
Re: Using unreferenced labels <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Nov 2008 19:37:00 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: atoi/atof
Message-Id: <slrnghu5md.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-14 04:41, Jürgen Exner <jurgenex@hotmail.com> wrote:
> debjyoti@gmail.com wrote:
>>I was messing around with a perl script and realized converting
>>strings to integers/floats is iffy on perl (compared to C).
>
> Really?
Yes, really. The Perl routines for converting between strings and
numbers are buggy.
> I haven't noticed.
I guess most people haven't, or the bugs would be fixed already. These
bugs have been there for a very long time, but they show up only if you
get close to the 15 digits/53 bits of FP precision.
I'm almost sure the OP's code is even buggier, though. String/number
conversions aren't trivial.
hp
------------------------------
Date: Sat, 15 Nov 2008 19:15:41 GMT
From: sln@netherlands.com
Subject: Re: atoi/atof
Message-Id: <cq7uh4hn2g4ccffbn2ojkvpf8u1io2l5hv@4ax.com>
On Fri, 14 Nov 2008 17:48:16 GMT, sln@netherlands.com wrote:
>On Thu, 13 Nov 2008 18:31:25 -0800 (PST), debjyoti@gmail.com wrote:
>
>>Hi all
>>
>>I was messing around with a perl script and realized converting
>>strings to integers/floats is iffy on perl (compared to C). There is
>>all this mention of atoi/atof being system dependent etc and so I
>>found this piece of code for atoi():
>>
>>sub atoi {
>> my $t;
>> foreach my $d (split(//, shift())) {
>
>Split() is being passed a string. So $d is now used as a string.
>$t here is unknown at this point.
>
>> $t = $t * 10 + $d;
> ^ ^
>Now $t and $d are being used as a number because of the *+ operators.
>If $d were not a digit, there might be a runtime error.
>
>> }
>> return $t;
>>}
>>
>[snip]
>
[snip]
I might as well be correct
>
>Typically, atoi() from C library does something like this:
>
>int _myatoi (char *p)
>{
> int num = 0, sign = 1, digit;
// assert(p);
if (!p) return 0;
while ((digit=*p)&& (digit == ' ' || digit == '\t')) p++;
if (digit == '-') {
sign = -1;
p++;
} else
if (digit == '+')
p++;
> while (digit = *p++) {
> if (!(digit >= '0' && digit <= '9'))
> return 0;
> num = num * 10 + (digit - '0');
> }
> return sign*num;
>}
>
>Good job though, I like your emulations.
>
>
>sln
------------------------------
Date: Sat, 15 Nov 2008 19:21:19 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: BigInt in per
Message-Id: <slrnghu4ov.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-12 17:32, Tux Tango <tux@nospam.ciuc.deu> wrote:
> I have a MSSQL database with bigint datatype. I am doing a simple SELECT
> query and printing out the information:
>
>
> my $qry = "SELECT C1, C2 FROM TABLE" ;
> my $sth = $dbh->prepare($qry);
> $sth->execute;
> while(my @row = $sth->fetchrow_array) {
> print "$row[0]\t$row[1]\n";
> }
>
> OUTPUT:
>
> 954925604786 1.00000000076029e+15
> 954925505262 1.00000000076023e+15
> 954925581159 1.00000000076028e+15
> 954925581160 1.00000000076028e+15
> 954925421109 1.00000000076019e+15
> 954925574965 1.00000000076027e+15
> 110978984447583 1.00000000076031e+15
>
>
> In the Database:
> 954925604786 1000000000760290
>
>
> any idea, how to convert the output?
Apparently the output *is* converted - from MSSQL bigint to a perl
floating point number. So I guess your question is really how you can
*prevent* this conversion. You probably can't (using bigint in Perl
probably doesn't help because this conversion occurs somewhere in the
DBD driver), but you can convert to a string instead:
my $qry = "SELECT to_char(C1), to_char(C2) FROM TABLE" ;
or something similar (to_char() is oracle-specific, afaik) should help.
hp
------------------------------
Date: Sat, 15 Nov 2008 19:43:19 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Client-Server Communication in Perl CGI
Message-Id: <slrnghu629.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-14 18:09, Jim Gibson <jimsgibson@gmail.com> wrote:
> In article
><0097acec-c52e-4ac4-8de0-0400d0a9b27a@k24g2000pri.googlegroups.com>,
> sri <sriseetha1986@gmail.com> wrote:
>> My client program is a browser, and the server may be run in perl, ror
>> or any other server side scripting. The browser has to send the
>> request to the server once, after that the server has to keep track of
>> the client and send the response frequently to the client.
>>
>> One way we can achieve this with Applets. Is there any other way to
>> achieve this ??
>
> Sounds like 'AJAX' to me.
Nope. AJAX doesn't magically allow the server to send something to the
browser without a request. Instead some JavaScript running in the
browser sends requests to the browser. So, for in the terminology you
use below, it is some kind of "client pull".
> I am only familiar with the concept, not the
> methods, so I can't say for sure. See
><http://en.wikipedia.org/wiki/Ajax_(programming)> for more info.
>
> For vanilla HTTP, the choice is "server push" and "client pull". See,
> for example <http://oreilly.com/openbook/cgi/ch06_06.html>.
>
> For an example of client pull, see
><http://www.stonehenge.com/merlyn/LinuxMag/col39.html>
>
------------------------------
Date: Sat, 15 Nov 2008 18:48:22 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <slrnghu2r9.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-07 14:55, Jürgen Exner <jurgenex@hotmail.com> wrote:
> "Peter Wyzl" <placebo@petergreen.id.au> wrote:
>>Yes but is there some 'authorative source' of what all the different
>>timezones are
These are notoriously incompatible between systems. For Linux just find
all files below /usr/share/zoneinfo. For Windows, there is probably some
API to get this information.
>>and the daylight times for those zones and when they switch
>>back and forth?
For converting between UTC and some timezone, you don't have to know
that. Just tell the system which timezone to use.
> 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.
That's why the Linux (or rather glibc) timezone system uses city names
as keys. So I use the "Europe/Vienna" timezone, and you would presumably
use the "Europe/Berlin" timezone (you may not live in Berlin, but AFAIK
all of Germany uses the the same DST rules - if the Bavarians had a
different system, there would be a "Europe/Munich" timezone. If there
are two different rules for different parts of a city, that can be
easily extended (for example, if the GDR used a different system than
the FRG, there could be a "Europe/East-Berlin" timezone).
hp
------------------------------
Date: Sat, 15 Nov 2008 18:53:53 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <slrnghu35i.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-07 13:42, Ted Byers <r.ted.byers@gmail.com> wrote:
> On Nov 7, 3:05 am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
>> Ted Byers schreef:
>>
>> > Ilya Zakharevich:
>> >> $ENV{TZ} = 'US/Pacific';
>> >> POSIX::settz(); # sp? tzset()?
>> >> print scalar localtime time;
>>
>> >> and get the correct local time.
>>
>> > 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?
>
> Actually no. This is to interact with a database on a server that
> serves a web application. Messing with the environment settings on
> the server for the timezone is guaranteed to fail.
The environment of a unix machine is a per-process property. Changing
the environment of one process doesn't affect other processes at all.
> For example, there could be simultaneous requests for data applicable
> to different locations.
That would only be a problem if these requests are served by the same
process and this process interleaves processing of these requests.
hp
------------------------------
Date: Sat, 15 Nov 2008 19:11:38 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 6.7 How can I make "\w" match national character sets?
Message-Id: <slrnghu46q.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-11 02:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> --------------------------------------------------------------------
>
> 6.7: How can I make "\w" match national character sets?
>
>
> Put "use locale;" in your script. The \w character class is taken from
> the current locale.
>
> See perllocale for details.
While this is the correct answer to the question, I think a better
answer would be the counter question: "Are you sure you need to use
national character sets? Could you use Unicode instead?"
hp
------------------------------
Date: Sat, 15 Nov 2008 20:21:07 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: HTML::Entities & UTF8
Message-Id: <slrnghu894.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-10 11:31, howa <howachen@gmail.com> wrote:
> Hello, consider my CGI program:
>
> #=======================
> use HTML::Entities;
> use utf8;
>
> print STDERR encode_entities( $q->param("q") ), "\n";
>
> #=======================
>
> The incoming page was set to UTF8 and the parameter is Chinese UTF8
> characters, but the output of the above codes give me:
>
>
> 中國人277
>
>
> I have already used utf8 and don't know what else I missed.
You missed two things:
1) "use utf8" means: "The source code of this program is in UTF-8". It
has no effect on the behaviour of your code at run-time. Since your
code (at least the obviously incomplete snippet you posted) contains
only ASCII characters, it has no effect at all.
2) The CGI module (I assume that $q is a CGI object) returns parameters
as raw byte strings (unless . You have to decode them yourself:
print STDERR encode_entities( decode( 'UTF-8', $q->param("q") ) ), "\n";
Alternatively, if you have a rather new version of the CGI module,
you can set the charset to 'utf-8':
$q->charset('utf-8');
print STDERR encode_entities( $q->param("q") ), "\n";
should work (this is completely undocumented and works only with
UTF-8 and also only if utf-8 is written in lower case. Beware!
hp
------------------------------
Date: Sat, 15 Nov 2008 21:44:17 GMT
From: sln@netherlands.com
Subject: Re: nested foreach loop
Message-Id: <diguh4971h9c4bno1ah9npcg7sc0vjpodq@4ax.com>
On Fri, 14 Nov 2008 16:43:11 -0800 (PST), torque <tariq.a.shaikh@gmail.com> wrote:
>I have a nested foreach loop and this is really killing the
>performance. The inner foreach is using the value from the outer loop
>to check if it is a valid value by comparing it against an array of
>valid values. I removed the inner foreach to eliminate validation and
>the performance improved from 12 hours to 3 hours for 7 million
>records.
>But I would like to have this validation check done by the inner
>foreach loop.
>
>This is how the code looks like. Its fairly simple but I am new to
>perl.
>
>open(WVHFILE, "<file.txt");
>while (<WVHFILE>)
>{
> chomp;
> ($id, $pk, $an, $eid, $vv, $val, $et) = split(/\|/);
> my @token = split(";", $val);
> my %rst = ();
> my $flg = 0;
> my $ed = substr($et,0,11);
>
> foreach $nvpair (@token)
> {
> $flg = 0;
> my ( $attr_id, $attr_val) = split ("=", $nvpair);
> foreach $aid (@attr_lst){
> if ($attr_id == $aid){
> $flg = 1;
> }
>
> }
>
> if ($flg == 1) {
> $rst{$attr_id} = $attr_val . "|" . $lst{$attr_id .
>$attr_val}. "|";
> }
>
> }
>
>Please send me an alternative if you know it. I would appreciate it.
>Thanks.
Here are some possibilites that may enhance performance.
sln
------------------------------------------------
Untested ...
# id | pk | an | eid | vv | val | et
# id | pk | an | eid | vv | @token = (attid=val : attid=val : attid=val) | et
# @attr_lst = (attid, attid, attid)
# -----------------------------------------------------
my %hattr_lst = map {$_ => ''} @attr_lst;
open(WVHFILE, "<file.txt");
while (<WVHFILE>)
{
chomp;
my %rst = ();
my %hseen = ();
####### if you just need token-list field ->
my @token = (); # only if need token
while ( /\s*([^|:]+)\s*=\s*([^|:]+)\s*[:|]/g )
{
# $1 = token:attid
# $2 = token:val
push @token, $1; # only if need token
if (exists $hattr_list{$1})
{
$rst{$1} = $2 . "|" . $lst{$1 . $2}. "|";
$hseen{$1}++;
}
}
# what is done down here?
####### or, if you need all the fields ->
($id, $pk, $an, $eid, $vv, $val, $et) = split(/\|/);
my $ed = substr($et,0,11);
my @token = (); # only if need token
while ( $val =~ /\s*([^:]+)\s*=\s*([^:]+)\s*/g )
{
# $1 = token:attid
# $2 = token:val
push @token, $1; # only if need token
if (exists $hattr_list{$1})
{
$rst{$1} = $2 . "|" . $lst{$1 . $2}. "|";
$hseen{$1}++;
}
}
# what is done down here?
####### or, to fix up original code ->
($id, $pk, $an, $eid, $vv, $val, $et) = split(/\|/);
my @token = split(";", $val);
my %rst = ();
my $ed = substr($et,0,11);
foreach $nvpair (@token)
{
my ( $attr_id, $attr_val) = split ("=", $nvpair);
if (exists $hattr_list{$attr_id})
{
$rst{$attr_id} = $attr_val . "|" . $lst{$attr_id . $attr_val}. "|";
$hseen{$attr_id}++;
}
}
# what is done down here?
------------------------------
Date: Sat, 15 Nov 2008 08:40:50 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: parameter error during function call
Message-Id: <cguth45db7u9ivaoa1j80jgsdn8p5ursih@4ax.com>
Slickuser <slick.users@gmail.com> wrote:
>How do I fix this. I need to pass in as scalar, hash, array.
>
>Odd number of elements in hash assignment at
>use strict;
>use warnings;
>
>my %chars_G =
>(
> 'a' => 'x',
> 'b' => 'y',
> 'c' => 'z',
> 'd' => 'a1',
> 'e' => 'a2',
> 'f' => 'a3'
>);
>
>my @info_G = (1,2,3,4,5);
>
>
>show_name("XYZ",%chars_G, @info_G);
Arguments are flattened, i.e. you are passing a total of 1+12+5 = 18
arguments.
See "perldoc perlsub", second paragraph, first sentence.
>sub show_name
>{
> my ($name,%chars,@info) = @_;
You are extracting 1+17 parameters, because %chars will slurp up all of
the rest, leaving none for @info. And 17 looks like an odd number to me,
so the error message is correct.
> How do I fix this. I need to pass in as scalar, hash, array.
See "perldoc perlsub", second paragraph, second sentence.
jue
------------------------------
Date: Sat, 15 Nov 2008 19:53:51 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: parameter error during function call
Message-Id: <slrnghu6m0.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-15 09:07, Mirco Wahab <wahab-mail@gmx.de> wrote:
> Slickuser wrote:
>> How do I fix this. I need to pass in as scalar, hash, array.
>>
>> Odd number of elements in hash assignment at
>> ...
>> show_name("XYZ",%chars_G, @info_G);
>>
>> sub show_name
>> {
>> my ($name,%chars,@info) = @_;
>> ...
>
> Use 'call by reference' if you want to
> avoid exactly that:
[...]
> show_name("XYZ", \%chars_G, \@info_G);
This is NOT "call by reference". You are passing a reference
explicitely. "Call by reference" is one of the ways a language can pass
parameters into a subroutine. In fact it is the one perl uses:
#!/usr/bin/perl
my $x = 5;
my $y = 6;
foo($x, $y);
print "$x, $y\n";
sub foo {
$_[0] = 3;
}
__END__
prints
3, 6
I.e, the subroutine parameters (in @_) contain references (in Perl
jargon: aliases) to $x and $y, and by modifying them the arguments are
modified.
The opposite is "call by value" as in C, where the subroutine receives a
copy of the arguments.
(I'll skip "call by name" as in Algol here).
hp
------------------------------
Date: Sat, 15 Nov 2008 08:18:40 -0800 (PST)
From: howa <howachen@gmail.com>
Subject: PHP's ob_gzhandler equivalent in Perl ?
Message-Id: <6f0edfbe-f7b0-4821-925c-c8cefaf4fe49@s9g2000prg.googlegroups.com>
In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
data to web browsers that support compressed web pages
Are there any similar stuff in CGI or related Perl modules?
Thanks.
------------------------------
Date: Sat, 15 Nov 2008 08:49:32 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: PHP's ob_gzhandler equivalent in Perl ?
Message-Id: <n6vth4t2eb43ppjkeivg1k457o88ma4lq5@4ax.com>
howa <howachen@gmail.com> wrote:
>In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
>data to web browsers that support compressed web pages
I've not heard of gz-encoding. Are you talking about GNU-zip, aka gzip,
aka tarballs?
>Are there any similar stuff in CGI or related Perl modules?
There are numerous modules at
http://search.cpan.org/search?query=gzip&mode=all
jue
------------------------------
Date: Sat, 15 Nov 2008 20:38:53 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: PHP's ob_gzhandler equivalent in Perl ?
Message-Id: <slrnghu9ag.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-15 16:49, Jürgen Exner <jurgenex@hotmail.com> wrote:
> howa <howachen@gmail.com> wrote:
>>In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
>>data to web browsers that support compressed web pages
>
> I've not heard of gz-encoding. Are you talking about GNU-zip, aka gzip,
Presumably, since gzip is one of the specified compression methods
specified in the HTTP protocol (the other two are "deflate" (uses the
same method as gzip, but a different header) and "compress").
> aka tarballs?
No. Tarballs are tar archives, i.e., collections of files serialized
into a single file. They are not necessarily compressed, and even if
they are compressed, they may be compressed by any compression method,
not just gzip (bzip2 and compress are also common).
>>Are there any similar stuff in CGI or related Perl modules?
>
> There are numerous modules at
> http://search.cpan.org/search?query=gzip&mode=all
Many web servers also have a compression module, so you may not have to
do anything in the CGI script at all.
hp
------------------------------
Date: Sat, 15 Nov 2008 18:59:52 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: python feature in perl?
Message-Id: <slrnghu3go.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-07 03:08, Mike <mikee@mikee.ath.cx> wrote:
> I like that in python you can say:
>
> if __name__ == "__main__"
> tests
This is a bad example. Perl already has a testing framework. If you want
to add tests to your module, put them into the t/ direcory, not inside
your module.
There might be better examples for when this feature is useful, but I
cannot think of any at the moment.
hp
------------------------------
Date: Sat, 15 Nov 2008 20:16:07 +0100
From: News123 <news123@free.fr>
Subject: Re: python feature in perl?
Message-Id: <491f1ff7$0$11567$426a34cc@news.free.fr>
Hi,
The equivalent construct is:
if (! caller){
# your code here
}
mostly coded as
sub main {
# your code here
}
__PACKAGE__->main() unless caller;
If I understood well it's called modulino and in my opinion useful.
something can be used as a module or as a stand alone (or demo) script
Referred for example in chapter 18 of
http://www.onlamp.com/pub/a/onlamp/2007/04/12/five-ways-to-improve-your-perl-programming.html
http://tinyurl.com/yurwtt
bye
N
Peter J. Holzer wrote:
> On 2008-11-07 03:08, Mike <mikee@mikee.ath.cx> wrote:
>> I like that in python you can say:
>>
>> if __name__ == "__main__"
>> tests
>
> This is a bad example. Perl already has a testing framework. If you want
> to add tests to your module, put them into the t/ direcory, not inside
> your module.
>
> There might be better examples for when this feature is useful, but I
> cannot think of any at the moment.
>
> hp
------------------------------
Date: Sat, 15 Nov 2008 17:37:00 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Using unreferenced labels
Message-Id: <slrnghtulh.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-11 05:54, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> Thinking of it more: the current implementation:
>
> Perl interpreter time to time talks to itself like:
> "Now I'm executing line 17".
> It memorizes the number, and uses it in reports and backtracking.
>
> For multi-line statements, having finer granularity than
> one-speach-per-statement is going to be a slowdown.
>
> On the other hand, if you tried to compile the (slightly edited) code
> above, you would see that at compile time, Perl gives much higher
> granularity: it pinpoints the contributing line almost exactly. Which
> leads to the following, alternative, algorithm:
>
> Store the line number of "the function call" (line with the name of
> the function, or with "->" of an indirect call?) in the compile
> tree's node for the function call. Use THIS line number when
> backtracking at runtime (as opposed to the line number of the last
> talking-to-itself).
>
> Hint hint,
Reini Urban talked about some work he's doing on the B modules at the
Twin-City Perl workshop last weekend. If I understood him correctly he's
thinking about changing this: Instead of having special "I'm here"
opcodes he would add a location field to each opcode.
hp
------------------------------
Date: Sat, 15 Nov 2008 17:47:42 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Using unreferenced labels
Message-Id: <slrnghtv9g.1qq.hjp-usenet2@hrunkner.hjp.at>
On 2008-11-11 03:54, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Tad J McClellan <tadmc@seesig.invalid> wrote:
>>Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>>
>>> #!/usr/bin/perl -w
>>> What # or which?
>>> line
>>> number
>>> should
>>> in
>>> your
>>> opinion
>>> be
>>> returned
>>> for
>>> this
>>> Perl
>>> statement
>>> at
>>> run
>>> time ? :;
>>> __END__
>>
>>
>>9.5
>>
>>(ie. the median line number of the statement)
>
> I don't see a line 9.5 or did you mean average?
The median is defined as a number for which the number of larger and
smaller elements are equal. For an odd number of elements, this is the
middle element. For an even number, it can be any number between the two
middle elements, but by convention, the average of the two middle
elements is used. So for the sequence 2 .. 17, the median is 9.5. (In
this case it is also the average, but in general the average and median
are not the same, for example, the average of (1, 2, 4, 8, 16, 32) is
10.5 but the median is 6 (or any real number > 4 and < 8))
hp
------------------------------
Date: Sat, 15 Nov 2008 20:14:06 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Using unreferenced labels
Message-Id: <gfnaie$1r3i$1@agate.berkeley.edu>
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Peter J. Holzer
<hjp-usenet2@hjp.at>], who wrote in article <slrnghtulh.1qq.hjp-usenet2@hrunkner.hjp.at>:
> > Store the line number of "the function call" (line with the name of
> > the function, or with "->" of an indirect call?) in the compile
> > tree's node for the function call. Use THIS line number when
> > backtracking at runtime (as opposed to the line number of the last
> > talking-to-itself).
> >
> > Hint hint,
>
> Reini Urban talked about some work he's doing on the B modules at the
> Twin-City Perl workshop last weekend. If I understood him correctly he's
> thinking about changing this: Instead of having special "I'm here"
> opcodes he would add a location field to each opcode.
IMO, this is very horrible. One should DECREASE size of compile tree,
not increase it... (The change I advise above is ONLY for a
particular node in the tree, which is not going to blow the memory
footprint much, thus won't change memory locality properties much...)
Hope this helps,
Ilya
------------------------------
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 1985
***************************************