s/^(.{1,$c_sz})//s;
$$self[BODY] .= $1;
$c_sz -= length($1);
Unfortunately, this doesn't work because regex quantfiers are rather annoyingly (It's 2023, folks. RAM is cheap) limited to what can be represented as positve, signed 16-bit integer - 1, ie, 32766.
OTOH, the substr-operator returns a so-called lvalue which means that
the following works:
for (substr($_, 0, $c_sz)) {
$$self[BODY] .= $_;
$c_sz -= length();
$_ = '';
}
Problem: I have a string of an unknown length accessible as $_ and need
to collect a string whose length is stored in a variable. This length
may be <, > or == the length of the current work string. The string or substring I need from the current work string has to be removed from it
and its actual length subtracted from the length in the variable.
Initially, I tried to do this with ($c_sz being the length variable)
s/^(.{1,$c_sz})//s;
$$self[BODY] .= $1;
$c_sz -= length($1);
Unfortunately, this doesn't work because regex quantfiers are rather annoyingly (It's 2023, folks. RAM is cheap) limited to what can be represented as positve, signed 16-bit integer - 1, ie, 32766.
with <87o7pg3w2o.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
*SKIP*
s/^(.{1,$c_sz})//s;
$$self[BODY] .= $1;
$c_sz -= length($1);
Unfortunately, this doesn't work because regex quantfiers are rather
annoyingly (It's 2023, folks. RAM is cheap) limited to what can be
represented as positve, signed 16-bit integer - 1, ie, 32766.
Your perl is 32bit. Get over it.
OTOH, the substr-operator returns a so-called lvalue which means that
the following works:
for (substr($_, 0, $c_sz)) {
$$self[BODY] .= $_;
$c_sz -= length();
$_ = '';
}
It's a pity that pseudo-looping is the only way to get aliasing.
Rainer Weikusat <rweikusat@talktalk.net> writes:
Problem: I have a string of an unknown length accessible as $_ and need
to collect a string whose length is stored in a variable. This length
may be <, > or == the length of the current work string. The string or
substring I need from the current work string has to be removed from it
and its actual length subtracted from the length in the variable.
Initially, I tried to do this with ($c_sz being the length variable)
s/^(.{1,$c_sz})//s;
$$self[BODY] .= $1;
$c_sz -= length($1);
Unfortunately, this doesn't work because regex quantfiers are rather
annoyingly (It's 2023, folks. RAM is cheap) limited to what can be
represented as positve, signed 16-bit integer - 1, ie, 32766.
This should work:
s/^(${\(".?" x $c_sz)})//s;
but I suggest it only as a Perl joke!
Eric Pozharski <whynot@pozharski.name> writes:
with <87o7pg3w2o.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
It's not.Unfortunately, this doesn't work because regex quantfiers are ratherYour perl is 32bit. Get over it.
annoyingly (It's 2023, folks. RAM is cheap) limited to what can be
represented as positve, signed 16-bit integer - 1, ie, 32766.
rw@brushfire:~/work/mad-http$ perl -e 'print ((1 << 63) + 15, "\n")' 9223372036854775823
This is just an abitrary limit compiled into it.
It's also not really pseudo-anything*SKIP*
for (<list>) {
<stmt>;
<stmt>;
<stmt>;
}
with <87fsardr2g.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
Eric Pozharski <whynot@pozharski.name> writes:
with <87o7pg3w2o.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
*SKIP*
It's not.Unfortunately, this doesn't work because regex quantfiers are ratherYour perl is 32bit. Get over it.
annoyingly (It's 2023, folks. RAM is cheap) limited to what can be
represented as positve, signed 16-bit integer - 1, ie, 32766.
rw@brushfire:~/work/mad-http$ perl -e 'print ((1 << 63) + 15, "\n")'
9223372036854775823
This is just an abitrary limit compiled into it.
This implies that whoever built your perl has explicitly set this
"arbitrary limit". Somehow I doubt it.
It's also not really pseudo-anything*SKIP*
for (<list>) {
<stmt>;
<stmt>;
<stmt>;
}
Well, how would you identify this construct then:
for ( $aa=42 ) { $_*=2 }
Eric Pozharski <whynot@pozharski.name> writes:*SKIP*
with <87fsardr2g.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
Eric Pozharski <whynot@pozharski.name> writes:
with <87o7pg3w2o.fsf@doppelsaurus.mobileactivedefense.com> Rainer
Weikusat wrote:
*SKIP*
It's not.Unfortunately, this doesn't work because regex quantfiers are rather >>>>> annoyingly (It's 2023, folks. RAM is cheap) limited to what can beYour perl is 32bit. Get over it.
represented as positve, signed 16-bit integer - 1, ie, 32766.
It's documented as such:
n and m are limited to non-negative integral values less than a
preset limit defined when perl is built. This is usually 32766
on the most common platforms.
I already wrote that. foreach is something like mapc in lisp: It takesIt's also not really pseudo-anythingWell, how would you identify this construct then:
for (<list>) {
<stmt>;
<stmt>;
<stmt>;
}
for ( $aa=42 ) { $_*=2 }
a block and a list as argument. It then aliases $_ to each element on
the list in turn and executes the block once everytime a new list
element has been aliased. A list of one element is just a list. Even a
list of 0 elements could be used for something:
----------
This is a funky comment for ();
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 495 |
Nodes: | 16 (3 / 13) |
Uptime: | 52:08:20 |
Calls: | 9,752 |
Calls today: | 12 |
Files: | 13,742 |
Messages: | 6,184,804 |