[25134] in Perl-Users-Digest
Perl-Users Digest, Issue: 7383 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 9 11:05:33 2004
Date: Tue, 9 Nov 2004 08:05:13 -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 Tue, 9 Nov 2004 Volume: 10 Number: 7383
Today's topics:
Re: $& imposes a considerable performance penalty they (Anno Siegel)
Re: $& imposes a considerable performance penalty they <uri@stemsystems.com>
Re: Binary files in PERL? <usenet@morrow.me.uk>
call pperl from c++ passing token list (Charlie)
Re: Extract a number from a string. <wyzelli@yahoo.com>
extracting the super classes of an object from the outs ()
Re: Finding two strings with the same crc32 <mshelor@cpan.dot.org>
Re: Finding two strings with the same crc32 <dzluk8fsxsw0001@sneakemail.com>
Re: Finding two strings with the same crc32 <dzluk8fsxsw0001@sneakemail.com>
Re: Finding two strings with the same crc32 <mshelor@cpan.dot.org>
Re: Finding two strings with the same crc32 <dzluk8fsxsw0001@sneakemail.com>
Re: Grabbing a PDF file from the web...how? <Joe.Smith@inwap.com>
Re: Grabbing a PDF file from the web...how? <usenet@morrow.me.uk>
Re: How to scan Keyboard in Perl or else on Linux ? <Raphael.Rochet@xilinx.com>
Re: installing extra file through ExtUtils::MakeMaker (Anno Siegel)
Re: map()'s BLOCK [was: "Re: Q: re Inline and Benchmark (Anno Siegel)
Re: matching all perldoc names but no more <usenet@morrow.me.uk>
Re: references to OTHER objects <usenet@morrow.me.uk>
Re: references to OTHER objects <mritty@gmail.com>
Re: references to OTHER objects <nospam@nospam.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Nov 2004 13:44:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: $& imposes a considerable performance penalty they say
Message-Id: <cmqhko$9ll$1@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uguttman@athenahealth.com> wrote in comp.lang.perl.misc:
> >>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>
> GH> Even if I have never tried to quantify the claimed performance
> GH> penalty caused by $&, I realize that your above examples are not
> GH> sufficient for drawing any conclusions. The point, if I have
> GH> understood it correctly, is that the use of $& *once* enables
> GH> capturing for *all* regular expressions in the program, also those
> GH> without capturing parentheses or capturing through $&.
>
> to clarify that, $& is a way to capture the entire match. it is similar
> to enclosing the regex in () and using $1. so by itself it is useful
> (golfers like it :). but in order to work properly it has a global side
> effect. since it always has the full match from the last regex, and it
> is a global var, if you use it once ANYWHERE in your code, the matched
> string (btw, this really only matters with s/// since it can change the
> original string) must be copied for all s/// even if you don't have any
> capturing parens. so in general, don't use it, use explicit capturing
> parens which will only cause the s/// with them to copy the original
> string.
>
> the OP's wimpy test didn't even come close to showing this issue. it
Here's a similarly wimpy test that does show the difference:
time perl -e '$_ = "x" x 10_000; $1 while /(x)/g'
0.290u 0.030s 0:00.32 100.0%
time perl -e '$_ = "x" x 10_000; $& while /(x)/g'
2.910u 0.030s 0:02.96 99.3%
You want a long string to match over to see the difference. The
point is that after use of $&, all of $`, $& and $' are active, and
so the whole string is copied on every match, as opposed to only
the match itself with "()".
Some weeks ago we had a case here where someone did that with a
multi-gigabyte string...
Anno
------------------------------
Date: Tue, 09 Nov 2004 14:39:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: $& imposes a considerable performance penalty they say
Message-Id: <x73bzj9jeg.fsf@mail.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>> the OP's wimpy test didn't even come close to showing this issue. it
AS> Here's a similarly wimpy test that does show the difference:
AS> time perl -e '$_ = "x" x 10_000; $1 while /(x)/g'
AS> 0.290u 0.030s 0:00.32 100.0%
AS> time perl -e '$_ = "x" x 10_000; $& while /(x)/g'
AS> 2.910u 0.030s 0:02.96 99.3%
AS> You want a long string to match over to see the difference. The
AS> point is that after use of $&, all of $`, $& and $' are active, and
AS> so the whole string is copied on every match, as opposed to only
AS> the match itself with "()".
try some minor changes. move the $& to somewhere else and use $1 in both
cases. that will show its global nature. and another variant would be to
not even grab when using $& and it will also do a full copy.
AS> Some weeks ago we had a case here where someone did that with a
AS> multi-gigabyte string...
yow!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 8 Nov 2004 23:59:43 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Binary files in PERL?
Message-Id: <fsd562-7p7.ln1@osiris.mauzo.dyndns.org>
Quoth Benjamin Khoo <benkhoo@copperblue.per.sg>:
> On Sun, 07 Nov 2004 16:08:19 +0000, Ben Morrow wrote:
> > Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
> >> Benjamin Khoo wrote:
> >> > i would like to find out how to write a binary file in PERL
> >> >
> >> > most of the readme and tutorial online only deal with writing ASCII
> >> > files.
> >>
> >> Are you really on an OS that differentiates between binary and text files?
> >
> > As of 5.8 Perl makes that difference regardless of OS. However, on some
> > OSen it defaults to binary and on some to a sort-of mixed text and
> > binary mode that is almost certainly completely useless... :)
> >
> > Ben
>
> i work on linux.. does that make a difference if it is binary or ascii?
> does that mean that using "binmode" might not give me a binary file as
> expected?
binmode will always give you a binary file, and should *always* be used
for one. Not doing so will lead to perl attempting to interpret the
contents of the file as (probably) ISO8859-1, and treat these as
characters, which may have strange effects if you later start using
Unicode.
Ben
--
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent? [Feynmann] ben@morrow.me.uk
------------------------------
Date: 9 Nov 2004 06:14:01 -0800
From: cs_hart@yahoo.com (Charlie)
Subject: call pperl from c++ passing token list
Message-Id: <a94b517d.0411090614.21235a83@posting.google.com>
I have a c++ program which contains numerous functions to perform
calculations on a list of tokens. Every time a calculation is
changed/added we need to change the program. I would like to put the
calculation routines in an external files and invoke them from the
program. It appears that perl may be a good fit for this (btw, I am
not a perl programmer).
Does this seem doable (or easy) with perl? Any pointers or tips for
getting started or thigs to look out for?
thanks...charlie
------------------------------
Date: Tue, 09 Nov 2004 11:08:30 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Extract a number from a string.
Message-Id: <Oy1kd.30290$K7.12626@news-server.bigpond.net.au>
"Adam" <adam_cheney@hotmail.com> wrote in message
news:214d0889.0411080642.7942a3e1@posting.google.com...
> "Peter Wyzl" <wyzelli@yahoo.com> wrote in message
> news:<CfIjd.27076$K7.12840@news-server.bigpond.net.au>...
<..>
> ($lic_usage{$lic_type}{$max}) = /(\d+)/ if (/Maximum/);
What happens here when /Maximum/ matches and /(\d+)/ fails to capture
anything?
You end up assigning whatever happens to be in $1 at that time (maybe
nothing, more likely the result of the last successful match) to
$lic_usage{$lic_type}{$max}. This is a _bad_ thing.
That is precisely why I showed it as two separate matches. See John Krahn's
post for a nice way to do both conditionals in a single line without that
risk.
--
Wyzelli
print '.sig goes here';
------------------------------
Date: 9 Nov 2004 15:31:19 GMT
From: bboett@sept.u-strasbg.fr ()
Subject: extracting the super classes of an object from the outside?
Message-Id: <cmqns7$i8i$1@news.u-strasbg.fr>
Hi!
another problem rose now....
uhm might seem stupid, but the ISA array is available only inside the
objects themselves, seems i can't acces them from the outside...
any way to get a hold of the super classes of an object?
--
ciao
Bruno
Bruno.Boettcher at visualsphere dot com
--
ciao
Bruno
Bruno.Boettcher at visualsphere dot com
------------------------------
Date: Tue, 09 Nov 2004 04:30:58 -0700
From: Mark Shelor <mshelor@cpan.dot.org>
Subject: Re: Finding two strings with the same crc32
Message-Id: <WfidnSFM6NfrNw3cRVn-iA@comcast.com>
Jonas Nilsson wrote:
> If I try to find two string that give the same crc32 however I don't
> succeed. I use the code below to spot strings that have the same first 28
> bits (to save memory I don't store all 32 bits). The code don't find any
> however even after checking 6 million strings!
>
> Why?
It's possible to find crc32 collisions without too much effort. Since
there are 2**32 possible CRC values, on average you'll need to search
only O(2**16) strings to find a collision.
I wrote a tiny Perl program that found the following collision in 91903
trails:
$string1 = "aaaaa0.462031558722291"
$string2 = "aaaaa0.0585754039730588"
These strings share a common CRC value of 1938556049.
If you're interested, here's the Perl program I used:
use strict;
use warnings;
use Digest::CRC qw(crc32);
my $c;
my $n;
my $r;
my %h;
srand;
for ($n = 0;; $n++) {
$r = "aaaaa" . rand();
$c = crc32($r);
if ($h{$c}) {
print "collision: $h{$c} and $r\n";
print "$n trials\n";
last;
}
$h{$c} = $r;
}
Regards, Mark
------------------------------
Date: Tue, 9 Nov 2004 12:35:04 +0100
From: "Jonas Nilsson" <dzluk8fsxsw0001@sneakemail.com>
Subject: Re: Finding two strings with the same crc32
Message-Id: <cmqa0s$77v$1@news.island.liu.se>
"Jonas Nilsson" <dzluk8fsxsw0001@sneakemail.com> wrote in message
news:cmq4na$5qm$1@news.island.liu.se...
> Just for fun I would like to find two strings that have the same crc32.
The
> probably of doing this for a set of for example one million strings is
more
> than 99.9999999999999999999999999999999999999999999999997%.
I found out that the differences can't be close (within the size of the
checksum that is ).
> If I try to find two string that give the same crc32 however I don't
> succeed. I use the code below to spot strings that have the same first 28
> bits (to save memory I don't store all 32 bits). The code don't find any
> however even after checking 6 million strings!
>
Modifying my program a bit gave me some other matching strings:
examples
Maria has nine red beds.
Steven has fifteen white tables.
Both have the crc32 "248210933"
Joe has fourteen magenta things.
Lars has thirteen black balls.
Both have the crc32 "93832682"
/jN
------------------------------
Date: Tue, 9 Nov 2004 12:42:00 +0100
From: "Jonas Nilsson" <dzluk8fsxsw0001@sneakemail.com>
Subject: Re: Finding two strings with the same crc32
Message-Id: <cmqads$78c$1@news.island.liu.se>
"Mark Shelor" <mshelor@cpan.dot.org> wrote in message
news:WfidnSFM6NfrNw3cRVn-iA@comcast.com...
> Jonas Nilsson wrote:
>
> > If I try to find two string that give the same crc32 however I don't
> > succeed. I use the code below to spot strings that have the same first
28
> > bits (to save memory I don't store all 32 bits). The code don't find any
> > however even after checking 6 million strings!
> >
> > Why?
>
>
> It's possible to find crc32 collisions without too much effort. Since
> there are 2**32 possible CRC values, on average you'll need to search
> only O(2**16) strings to find a collision.
>
> I wrote a tiny Perl program that found the following collision in 91903
> trails:
>
> $string1 = "aaaaa0.462031558722291"
> $string2 = "aaaaa0.0585754039730588"
>
By random searching instead of systematic I quickly found a lot of matches
(with crc32 below):
/jN
oxueekz
pyqptgs
1122772949
nktteme
qjpatal
1867444077
nuktjcj
bimxkml
2973957111
atimtna
nfxqcvx
4014160497
tgnvsia
kfjcbeh
550598113
kmswcnn
hcdguxq
4090013392
vswkuqk
yafwbir
2261340929
yezrovl
vwknxnu
2954574600
cujnfpg
phhwvrh
3289759799
xucsdhf
gtgfudo
4164393361
gqplbmq
hcapuuh
656642059
igeougy
ytpfssi
4118505601
driaytu
hnomxzs
2212230278
iketcbk
jerdutt
2479104683
rpppuko
mqtedgf
1986672624
kvbesjh
twfpbfa
2892019439
evwzaos
zwsopcz
3029719102
ugtegak
jfppvmb
3715719613
iknybbk
jeyittt
398238032
itqfybq
jzfvotn
3806847855
ywouxys
ukiyywu
3626703900
zqlzlzj
vmjvmtl
1949335477
aitjoui
qzaciay
3794947975
vxhmxnl
yjyqovu
1882453027
zpshpoa
ubbtgwx
311908063
exhzdhp
jjyfspi
3165437067
xsdmynd
knftilk
2149740729
tohzrgd
xsnvsib
3862892194
sgkldej
lfoyuic
809259157
izzndbw
fhkrszn
2534674167
kjkkgzg
xwirwxh
4108936481
yvwjyuh
jkusiwg
1821358308
fxtdmbs
vkamkvc
4104486534
ftqxzdh
ezfhlrw
2484994613
hvaledh
xetecpx
554199908
yeissqw
jxkjcsx
4294947840
sdpoqcw
cwefwwg
2627502466
nepvour
rjcshod
110262302
cvivwhc
pkkogjl
136192574
bygmhsd
qdetxqk
1195331540
obwpuxb
smdurbt
2466482257
iwuhnto
eksdozi
2396159347
cjegpcp
ovckqmv
861582261
dpozeev
hlivdkp
430397453
tianznw
gtcwjlx
3110265897
xcsjggh
hpfcasx
36665361
xzxuysm
kgzliqb
287371322
chihdwk
otodeym
1558575868
tnkxzms
koomkaz
3085259689
kceezbm
tbapknd
4198087903
wlwfvnq
kcdcqtg
304773531
oewnsln
cyqbrbh
492142473
tobzbve
knfoszl
2490869493
zxytuar
yvndcwm
2991426191
ecvoads
zbrzphz
1591549120
zgffxfz
yiqvnpe
288303136
twuzdyi
xksvewo
596722119
rfsgnet
bufnhqd
756968307
euuhciw
jgdttqn
3764572437
whprspf
kgcwtjp
3048824742
ymlbinm
flhwxbd
308304037
dupnrrz
tfegtfj
1644000365
axmicjj
reopshe
146039524
djqgnyv
tydnhmf
745237997
nwvmesa
rxehbiw
2678562110
gdsfrzk
hvbzebr
3101837067
zehmtce
edlxeol
3451105439
bzqdqlf
atftgzy
1671489439
silhbdt
czyadpd
3505195570
bzrxqyr
atehgom
329271041
rngqazj
mocdpvc
492217567
gdnftyq
xejseux
4065378867
flodegc
ymkqtkj
352398593
ejidvrz
jxxxajc
810447580
dexsuqr
tvmzseb
3499196161
vyzlbpd
fjoeddt
3537376586
yrhzlkq
unnvmew
4017118138
lxmoaip
syizpey
2579702319
zpcpays
eqgepuz
354399221
azizsuh
rgkccwg
3441578396
qzpwdlz
bgrntnu
1152814553
uwbrthp
zesncpi
3104178606
anhjdzw
rsjstxx
736480241
hhfncss
gzwrtkj
2341875164
jdjqdpe
vkytcjs
2096604753
mceivsy
qlvlqio
2468755540
mykpeip
rxoetey
1960566923
wqjcbhb
hpnvsdk
3406243371
wnflwjz
kauippl
2678321277
jxeiyfg
yegpidh
4185286856
phwijrf
cuupzpi
1692899291
uzhiqpm
fgjparb
803662884
------------------------------
Date: Tue, 09 Nov 2004 04:55:41 -0700
From: Mark Shelor <mshelor@cpan.dot.org>
Subject: Re: Finding two strings with the same crc32
Message-Id: <8P6dnb4vALLcLQ3cRVn-uQ@comcast.com>
Jonas Nilsson wrote:
> By random searching instead of systematic I quickly found a lot of matches
> (with crc32 below):
> /jN
>
> oxueekz
> pyqptgs
> 1122772949
A good illustration of the "birthday paradox".
But, can you come up with an efficient Perl program that finds an input
string whose CRC value is 1756683253?
Hint: I'd recommend writing it in C! ;)
------------------------------
Date: Tue, 9 Nov 2004 13:27:43 +0100
From: "Jonas Nilsson" <dzluk8fsxsw0001@sneakemail.com>
Subject: Re: Finding two strings with the same crc32
Message-Id: <cmqd3k$7v6$1@news.island.liu.se>
"Mark Shelor" <mshelor@cpan.dot.org> wrote :
>
> But, can you come up with an efficient Perl program that finds an input
> string whose CRC value is 1756683253?
>
> Hint: I'd recommend writing it in C! ;)
Shall I write a Perl-program in C?
I'm currently running this:
use strict;
use Digest::CRC qw(crc32 crc16);
my $string='aaaaaaa';
$|=1;
while (1) {
if (crc32($string)==1756683253) {
print $string;
exit;
}
$string++;
}
Which finishes after a maximum time of 44 hours. Just wait and see.
(Or should I start from 'zzzzzzz' working down?)
/jN
------------------------------
Date: Tue, 09 Nov 2004 11:09:35 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Grabbing a PDF file from the web...how?
Message-Id: <Pz1kd.66935$HA.60511@attbi_s01>
funkyville wrote:
> This approach won't work with PDFs.
> Does anyone know what to do?
> Do I need special modules? What am I missing?
You've got two problems. Other people have pointed out that get() is
not the appropriate method for getting+storing files. The other problem
is that you should be using binmode() when dealing with binary files.
binmode FILE; print FILE $content;
-Joe
------------------------------
Date: Tue, 9 Nov 2004 00:49:18 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Grabbing a PDF file from the web...how?
Message-Id: <epg562-7p7.ln1@osiris.mauzo.dyndns.org>
Quoth dean@realideas.com (funkyville):
> All I need my script to do is go to a website and download a .pdf from
> that site and save it to my hard drive. Example,
> http://www.anysite.com/report.pdf
>
> How do I do it?
> I've searched for hours (groups, CPAN, etc.) and can't find anything.
>
> For a normal html page I would just do something like this:
>
> use LWP::Simple;
> my $url;
> my $content;
> $url = "http://www.yahoo.com";
> $content = get($url);
>
> #then save
> open(FILE, ">>C:/temp/new.html") || die "$!";
You want '>', not '>>'.
Use three-arg open.
Use lexical FHs.
Use low-prec or.
open my $PDF, '>', 'C:/temp/new.pdf' or die "can't create new.pdf: $!";
PDFs are binary, so you need
binmode $PDF;
as well.
> print FILE $content;
> close(FILE);
No need for this with lexical FHs.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: Tue, 09 Nov 2004 16:28:38 +0100
From: =?ISO-8859-1?Q?Rapha=EBl?= <Raphael.Rochet@xilinx.com>
Subject: Re: How to scan Keyboard in Perl or else on Linux ?
Message-Id: <cmqnn7$rlm1@cliff.xsj.xilinx.com>
Hi,
I didn't find what I needed even in the ReadKey CPAN package ... so I
finally followed the Måns advise even if it's not portable to none unix
platforms.
I checked how is done the xkbwatch source code and I wrote my own
procedure (mainly because I don't need the xkbwatch graphical interface).
Now I call it from my perl script and it works fine !
Thanks everybody,
Raphaël.
Måns Rullgård wrote:
> Raphaël <Raphael.Rochet@xilinx.com> writes:
>
>
>>Hi,
>>
>>On Linux, does somebody know how to get the keyboard status in Perl ?
>>
>>I explane :
>>-> I would like to write a Perl script which scan the keyboard and
>>return the list of pressed keys.
>>
>>For example, let "keyboard_scan()" be the name of this function, with
>>the following behavior:
>>
>> - When keyboard_scan() is called, if the user is pressing no
>> keys, I would like keyboard_scan() to return the empty string
>> "".
>> - When keyboard_scan() is called, if the user is pressing the
>> CTRL key, I would like keyboard_scan() to return the code
>> string of the CTRL key.
>> - When keyboard_scan() is called, if the user is pressing the
>> ALT key and the SHIFT key, I would like the function to return
>> the string containing the code of the SHIFT key and the code
>> of the ALT key.
>>etc ...
>>
>>Or perhaps somebody knows how to do it in another language (C, TCL, ...) ?
>
>
> Are you running under X? Look at the source of xkbwatch. It displays
> the status of the modifier keys.
>
------------------------------
Date: 9 Nov 2004 11:53:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: installing extra file through ExtUtils::MakeMaker
Message-Id: <cmqb4f$3u2$2@mamenchi.zrz.TU-Berlin.DE>
Abdul-Wahid Paterson <aw@lintrix.net> wrote in comp.lang.perl.misc:
> Hi,
>
> I have been using ExtUtils::MakeMaker in a Makefile.PL to package and
> install a perl script and a few perl modules. At the moment my
> Makefile.PL is very simple, I just copied it from a few examples.
>
> I am now wanting to have a few templates and configuration files
> installed by "make install" but was not sure what I should put in my
> Makefile.PL to acheive this. Can anyone give me any examples of how to
> install extra supporting files?
Put them in MANIFEST. Better yet, build yourself a good MANIFEST.SKIP
and run "make manifest" after adding a file.
Anno
------------------------------
Date: 9 Nov 2004 12:55:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: map()'s BLOCK [was: "Re: Q: re Inline and Benchmark"]
Message-Id: <cmqen4$7nj$1@mamenchi.zrz.TU-Berlin.DE>
? the Platypus {aka David Formosa} <dformosa@zeta.org.au> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
>
> > Michele Dondi <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
>
> [...]
>
> > > Well, I guess I can live with it too. Especially since I had never
> > > even noticed up until now! However, out of curiosity: do you think
> > > that it "ought" to be allowed, hypothetically speaking?
> >
> > It ought to work if we expected orthogonal design: Never mind what kind
> > of block, "use" and "no" can go into it. But this is Perl...
>
> I don't think this is fair, perl brakes orthogonality when
> orthogonality makes things harder. When orthogonality makes things
> easer then orthogonality shouldn't be broken.
That's an ideal. In practice, Perl has broken orthogonality for all
kinds of reasons. Think of the use of filehandles. Very little in
the the mess of rules and exceptions that govern this are actually
to the convenience of the programmer, but to make some things possible
at all in an existing framework. Similarly, I'm happy to be able to
use "use" and "no" in most blocks. Exceptions come with the territory.
Anno
------------------------------
Date: Tue, 9 Nov 2004 00:46:53 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: matching all perldoc names but no more
Message-Id: <tkg562-7p7.ln1@osiris.mauzo.dyndns.org>
Quoth "Alan J. Flavell" <flavell@ph.gla.ac.uk>:
> On Mon, 8 Nov 2004, wana wrote:
> > Jim Gibson wrote:
> >
> > > In article <10oq6todvqrl2e8@news.supernews.com>, wana
>
> > >> I only avoided \w because perlre states that it is not portable
> > >> across character sets and may be insecure, which is critical in
> > >> my case. That may or may not be an issue in my program.
>
<snip>
>
> It'll reliably do a specific job. I'd suggest that the use of the
> word "unsafe" in the documentation is a bit misleading. I think in
> this specific reference it means "might not do what the naive reader
> expects"; but "unsafe" often refers to the possibility of malicious
> data causing security-relevant damage to result (such as, for example,
> unintended interpolation taking place using externally-derived data),
> and that's not what is intended here, AFAICS.
The locale is externally-derived data. A malicious user could (under
some OSen at least) construct their own locale that said ';' was a word
character.
I would hope (but I haven't tested) that if 'use locale' is in effect
and the locale setting was tainted then such regexen won't untaint...
One can always secure things by explicitly asking for the C locale, or
simply not using 'locale', which will cause \w to match what you expect.
> > but \w may vary in different locales.
>
> Which, in some situations, might be exactly what one wants.
Of course, but not when dealing with shell metachars.
Ben
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Tue, 9 Nov 2004 00:21:08 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: references to OTHER objects
Message-Id: <k4f562-7p7.ln1@osiris.mauzo.dyndns.org>
Quoth "Paul Lalli" <mritty@gmail.com>:
>
> Are you sure you want to do that? An object is already a reference.
<snip valid points>
> Correct. An object is a reference (usually to a hash, but it could be a
> reference to an array or even to a scalar) that has been blessed into a
> particular class.
You may think this picky, but the object is actually the referant (sp?),
not the reference (or, at least, it is the referant that is blessed). If
you deref it and take a new reference (or, indeed, simply copy the ref
value into a new scalar variable) the 'blessing' stays; it is not
connected to the original reference that the blessing was done through.
So, the OP is indeed always dealing with references to objects, as is
usual in OO languages.
Ben
--
Razors pain you / Rivers are damp
Acids stain you / And drugs cause cramp. [Dorothy Parker]
Guns aren't lawful / Nooses give
Gas smells awful / You might as well live. ben@morrow.me.uk
------------------------------
Date: Tue, 09 Nov 2004 14:57:42 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: references to OTHER objects
Message-Id: <GV4kd.712$Bj2.481@trndny01>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:k4f562-7p7.ln1@osiris.mauzo.dyndns.org...
>
> Quoth "Paul Lalli" <mritty@gmail.com>:
> >
> > Are you sure you want to do that? An object is already a reference.
> <snip valid points>
> > Correct. An object is a reference (usually to a hash, but it could
be a
> > reference to an array or even to a scalar) that has been blessed
into a
> > particular class.
>
> You may think this picky, but the object is actually the referant
(sp?),
> not the reference (or, at least, it is the referant that is blessed).
It had never occured to me to make the distinction. I stand better
educated.
Thank you,
Paul Lalli
------------------------------
Date: Tue, 9 Nov 2004 10:57:22 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1100015918.680132@nntp.acecape.com>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:k4f562-7p7.ln1@osiris.mauzo.dyndns.org...
> You may think this picky, but the object is actually the referant (sp?),
> not the reference (or, at least, it is the referant that is blessed). If
> you deref it and take a new reference (or, indeed, simply copy the ref
> value into a new scalar variable) the 'blessing' stays; it is not
> connected to the original reference that the blessing was done through.
>
ben, if i may ask you...was there a danger in the way i did it OP wise?
mind you, i quickly changed it so i just passed the reference...wait perhaps
i better rephrase that. up to what i have learned, if i have it right, Perl
manages allocated memory...if i have a reference to a variable, Perl will
hold on to the memory for that variable (so you don't lose it) while the
variable is still within scope. i don't have my books handy or i would go
to them right now "cause i can sorta see the page in my head"....if this is
right, does the same apply to objects?
thank for yoru time
------------------------------
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 V10 Issue 7383
***************************************