[30245] in Perl-Users-Digest
Perl-Users Digest, Issue: 1488 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 28 16:15:07 2008
Date: Mon, 28 Apr 2008 13:14:53 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 28 Apr 2008 Volume: 11 Number: 1488
Today's topics:
Regex for "at start of line OR preceded by space". <lonewolf@well.com>
Re: Regex for "at start of line OR preceded by space". <noreply@gunnar.cc>
Re: Regex for "at start of line OR preceded by space". <devnull4711@web.de>
Re: Regex for "at start of line OR preceded by space". <1usa@llenroc.ude.invalid>
Re: Regex for "at start of line OR preceded by space". <rvtol+news@isolution.nl>
Re: Regex for "at start of line OR preceded by space". dummy@phony.info
Re: Regex for "at start of line OR preceded by space". <1usa@llenroc.ude.invalid>
Re: script to find the files with very long names <jurgenex@hotmail.com>
Re: script to find the files with very long names <someone@example.com>
Tried to make an exe with par <horndasch.andreas@web.de>
untaint a hash eval <ddp23@cam.ac.uk>
Re: untaint a hash eval <benkasminbullock@gmail.com>
Re: untaint a hash eval <1usa@llenroc.ude.invalid>
Re: untaint a hash eval <noreply@gunnar.cc>
Re: untaint a hash eval <ddp23@cam.ac.uk>
Re: untaint a hash eval <benkasminbullock@gmail.com>
Re: untaint a hash eval xhoster@gmail.com
Re: untaint a hash eval xhoster@gmail.com
Re: untaint a hash eval <benkasminbullock@gmail.com>
Re: use of DBI; I am getting multiple error messages mi <cwilbur@chromatico.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 26 Apr 2008 23:17:11 -0700
From: "Robbie Hatley" <lonewolf@well.com>
Subject: Regex for "at start of line OR preceded by space".
Message-Id: <qf6dnbLkeM-1h4nVnZ2dnUVZ_vOdnZ2d@giganews.com>
I needed a regex that says "either at the start of a line, OR
preceded by some whitespace".
The whitespace (if any) is not to be part of the match.
That part I know how to do with lookbehind:
(?<=\s)($Regex1)
Start of line is easy too:
^($Regex1)
but when I tried to or them together:
my $Regex2 = qr{^|(?<=\s)($Regex1)};
But for some reason, it matches the empty string at the beginning
of every input string. Why is that?
What I finally came up with that works is:
my $Regex2 = qr{((?:^$Regex1)|(?:(?<=\s)$Regex1))};
That's pretty messy, tho. Are there easier ways of
doing this that I don't see?
--
Curious,
Robbie Hatley
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
perl -le 'print "\150ttp\72//\167ww.\167ell.\143om/~\154onewolf/"'
------------------------------
Date: Sun, 27 Apr 2008 08:54:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <67im8oF2ocdc2U1@mid.individual.net>
Robbie Hatley wrote:
> I needed a regex that says "either at the start of a line, OR
> preceded by some whitespace".
>
> The whitespace (if any) is not to be part of the match.
> That part I know how to do with lookbehind:
>
> (?<=\s)($Regex1)
>
> Start of line is easy too:
>
> ^($Regex1)
>
> but when I tried to or them together:
>
> my $Regex2 = qr{^|(?<=\s)($Regex1)};
>
> But for some reason, it matches the empty string at the beginning
> of every input string. Why is that?
>
> What I finally came up with that works is:
>
> my $Regex2 = qr{((?:^$Regex1)|(?:(?<=\s)$Regex1))};
>
> That's pretty messy, tho. Are there easier ways of
> doing this that I don't see?
It's hard to tell, since you don't show us what's in $Regex1 together
with some sample data.
Assuming that possible whitespace _may_ be part of the match, while you
capture what's matched by the $Regex1 part, you can do:
my $Regex2 = qr{^\s*($Regex1)};
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 27 Apr 2008 09:25:12 +0200
From: Frank Seitz <devnull4711@web.de>
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <67io3aF2ohi82U1@mid.individual.net>
Robbie Hatley wrote:
>
> my $Regex2 = qr{^|(?<=\s)($Regex1)};
>
> But for some reason, it matches the empty string at the beginning
> of every input string. Why is that?
Because | has a low precedence.
> What I finally came up with that works is:
>
> my $Regex2 = qr{((?:^$Regex1)|(?:(?<=\s)$Regex1))};
>
> That's pretty messy, tho. Are there easier ways of
> doing this that I don't see?
qr{(^|(?<=\s))($Regex1)}
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Sun, 27 Apr 2008 23:46:31 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <Xns9A8DC92A0C7C7asu1cornelledu@127.0.0.1>
"Robbie Hatley" <lonewolf@well.com> wrote in news:qf6dnbLkeM-
1h4nVnZ2dnUVZ_vOdnZ2d@giganews.com:
> I needed a regex that says "either at the start of a line, OR
> preceded by some whitespace".
The only difference between this criterion and "preceded by whitespace"
can occur at the beginning of the string. Therefore:
#!/usr/bin/perl
my $x = <<EOSTR;
Test1 Test2
Test3 Test4 Test5
Test6
Test7 Test8
Test9
Test0a
EOSTR
print "$1\n" while $x =~ /(?:\A|\s+)(\S+)/g ;
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Mon, 28 Apr 2008 09:06:37 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <fv4469.tc.1@news.isolution.nl>
Robbie Hatley schreef:
> I needed a regex that says "either at the start of a line, OR
> preceded by some whitespace".
Maybe you are looking for \b?
> my $Regex2 = qr{^|(?<=\s)($Regex1)};
The alternation was: BOL or whitespace. So why not write that first?
(?:\A|(?<=\s))
Ah, now I see, you just forgot to group it.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Mon, 28 Apr 2008 01:06:57 -0700
From: dummy@phony.info
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <9o0b141g8e2ivkr4busd3eb60mc0bq6c6m@4ax.com>
On Sun, 27 Apr 2008 23:46:31 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:
>"Robbie Hatley" <lonewolf@well.com> wrote in news:qf6dnbLkeM-
>1h4nVnZ2dnUVZ_vOdnZ2d@giganews.com:
>
>> I needed a regex that says "either at the start of a line, OR
>> preceded by some whitespace".
>
>The only difference between this criterion and "preceded by whitespace"
>can occur at the beginning of the string. Therefore:
>
>#!/usr/bin/perl
>
>my $x = <<EOSTR;
>Test1 Test2
> Test3 Test4 Test5
> Test6
>Test7 Test8
>Test9
> Test0a
>
>EOSTR
>
>print "$1\n" while $x =~ /(?:\A|\s+)(\S+)/g ;
On my XP machine that produces:
Test1
Test2
Test3
Test4
Test5
Test6
Test7
Test8
Test9
Test0a
But this:
use strict; use warnings;
while (<DATA>) {
print "$1\n" if /^\s*(\S+)(?:\s|$)/;
}
__DATA__
Test1 Test2
Test3 Test4 Test5
Test6
Test7 Test8
Test9
Test0a
Gives:
Test1
Test3
Test6
Test7
Test9
Test0a
which I think is better?
------------------------------
Date: Mon, 28 Apr 2008 08:50:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Regex for "at start of line OR preceded by space".
Message-Id: <Xns9A8E3151365B1asu1cornelledu@127.0.0.1>
dummy@phony.info wrote in
news:9o0b141g8e2ivkr4busd3eb60mc0bq6c6m@4ax.com:
> On Sun, 27 Apr 2008 23:46:31 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
>
>>"Robbie Hatley" <lonewolf@well.com> wrote in news:qf6dnbLkeM-
>>1h4nVnZ2dnUVZ_vOdnZ2d@giganews.com:
>>
>>> I needed a regex that says "either at the start of a line, OR
>>> preceded by some whitespace".
>>
>>The only difference between this criterion and "preceded by
>>whitespace" can occur at the beginning of the string. Therefore:
>>
>>#!/usr/bin/perl
>>
>>my $x = <<EOSTR;
>>Test1 Test2
>> Test3 Test4 Test5
>> Test6
>>Test7 Test8
>>Test9
>> Test0a
>>
>>EOSTR
>>
>>print "$1\n" while $x =~ /(?:\A|\s+)(\S+)/g ;
>
> On my XP machine that produces:
> Test1
> Test2
> Test3
> Test4
> Test5
> Test6
> Test7
> Test8
> Test9
> Test0a
>
> But this:
>
> use strict; use warnings;
> while (<DATA>) {
> print "$1\n" if /^\s*(\S+)(?:\s|$)/;
> }
> __DATA__
> Test1 Test2
> Test3 Test4 Test5
> Test6
> Test7 Test8
> Test9
> Test0a
>
> Gives:
> Test1
> Test3
> Test6
> Test7
> Test9
> Test0a
>
> which I think is better?
How can that be better?
Read the OP's criterion again:
>>> I needed a regex that says "either at the start of a line, OR
>>> preceded by some whitespace".
Yours misses Test2, Test4, Test5 and Test8 which are all preceded by
whitespace.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Sat, 26 Apr 2008 14:08:00 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: script to find the files with very long names
Message-Id: <ngd614hv6okum7vkub143cdib6t5hrnnpb@4ax.com>
Ed Morton <morton@lsupcaemnt.com> wrote:
>On 6/12/2006 2:34 AM, pui ming Wong wrote:
>> My objective is to go down the current directory
>> and have the system tells me which files have their names
>> longer than say 26 characters
>>
>> i think mixing the unix find command
>> with some other commands might do it.
>> But a perl script might do it more tidily and faster ?
File::Find with a simple
{print if lenght > 26}
as the wanted function should do nicely.
jue
------------------------------
Date: Sat, 26 Apr 2008 17:47:31 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: script to find the files with very long names
Message-Id: <TUJQj.2500$XI1.1804@edtnps91>
J=FCrgen Exner wrote:
> Ed Morton <morton@lsupcaemnt.com> wrote:
>> On 6/12/2006 2:34 AM, pui ming Wong wrote:
>>> My objective is to go down the current directory
>>> and have the system tells me which files have their names
>>> longer than say 26 characters
>>>
>>> i think mixing the unix find command=20
>>> with some other commands might do it.
>>> But a perl script might do it more tidily and faster ?
>=20
> File::Find with a simple
> {print if lenght > 26}
> as the wanted function should do nicely.
s/lenght/length/;
John
--=20
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Sun, 27 Apr 2008 23:23:36 -0700 (PDT)
From: Andy1407 <horndasch.andreas@web.de>
Subject: Tried to make an exe with par
Message-Id: <58197f84-ed42-4c33-b105-b6427ad44c25@24g2000hsh.googlegroups.com>
Hi,
i tried to make an binary file for windows using par.
i use the command: 'pp -o text.exe test.pl'
the content of test.pl is:
<---
#!/usr/bin/perl
print "hello world!\n";
<---
because i am using windows xp i also tried
<---
#!C:\perl\bin\perl
print "hello world!\n";
<---
This works on the console with 'perl test.pl' perfect...
when executing the command i still get:
<---
PAR::StrippedPARL::Static->get_raw() did not return the raw binary
data for a PAR loader at C:/Perl/site/lib/PAR/StrippedPARL/Base.pm
line 141, <DATA> line 1.
Could not write temporary parl (class PAR::StrippedPARL::Static) to
file 'C:\DOKUME~1\HORNDA~1\LOKALE~1\Temp\parlEMI9.exe' at C:/Perl/
site/
lib/PAR/StrippedPARL/Base.pm line 65, <DATA> line 1.
C:\Perl\site\bin/pp: Failed to extract a parl from
'PAR::StrippedPARL::Static' to file 'parlJQkKhen.exe' at C:/Perl/
site/
lib/PAR/Packer.pm line 1157, <DATA> line 1.
<---
how could i fix that?
Thanks for help
Andy
------------------------------
Date: 26 Apr 2008 11:49:21 GMT
From: Daniel Parry <ddp23@cam.ac.uk>
Subject: untaint a hash eval
Message-Id: <slrng165m1.rv.ddp23@pip.srcf.ucam.org>
Hello all,
I was wondering if anyone could give me some pointers as to the
best way to untaint the assocative array %config in the following
snippet please? Do I need to check its content against a suitable
regexp somehow? Or maybe I should use another method to read in
the file contents, though I'd prefer to not to have to include
any cpan libraries...
no strict;
if ( open( CONFIG, "$configFile" ) ) {
my $readConfig = "";
while ( <CONFIG> ) { $readConfig .= $_; }
eval $readConfig;
%config = %{ $userconfig };
close( CONFIG );
}
else {
die "Could not read config file: $configFile!";
}
use strict;
Thanks in advance for any help!
Best wishes,
Daniel
------------------------------
Date: Sat, 26 Apr 2008 13:28:14 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: untaint a hash eval
Message-Id: <fuvale$i7a$1@ml.accsnet.ne.jp>
On Sat, 26 Apr 2008 11:49:21 +0000, Daniel Parry wrote:
> Hello all,
>
> I was wondering if anyone could give me some pointers as to the best way
> to untaint the assocative array %config in the following snippet please?
> Do I need to check its content against a suitable regexp somehow? Or
> maybe I should use another method to read in the file contents, though
> I'd prefer to not to have to include any cpan libraries...
The documentation is in perldoc perlsec:
"Values may be untainted by using them as keys in a hash; otherwise the
only way to bypass the tainting mechanism is by referencing subpatterns
from a regular expression match."
> no strict;
> if ( open( CONFIG, "$configFile" ) ) {
> my $readConfig = "";
> while ( <CONFIG> ) { $readConfig .= $_; } eval $readConfig;
Assuming you actually care about the security of your script, the
untainting should be done before you "eval" the thing you've read in.
Otherwise, the above is probably the single most insecure thing you can
do in a Perl script.
As described above, to blanket untaint $readConfig, just match it against
any regular expression and use any substring match. Here is an example
program:
#!/usr/bin/perl -T
use warnings;
use strict;
use Scalar::Util 'tainted';
my $try;
sub print_tainted
{
$try++;
my ($what) = @_;
print "$try: ";
print "not " unless (tainted($what));
print "tainted\n" ;
}
my $job = <STDIN>;
print_tainted($job);
$job =~ /^(.*)$/s;
$job = $1;
print_tainted($job);
------------------------------
Date: Sat, 26 Apr 2008 14:04:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: untaint a hash eval
Message-Id: <Xns9A8C667C79A08asu1cornelledu@127.0.0.1>
Daniel Parry <ddp23@cam.ac.uk> wrote in news:slrng165m1.rv.ddp23
@pip.srcf.ucam.org:
> I was wondering if anyone could give me some pointers as to the
> best way to untaint the assocative array %config in the following
> snippet please? Do I need to check its content against a suitable
> regexp somehow?
Don't bother. Use a proper configuration parser module.
> Or maybe I should use another method to read in
> the file contents, though I'd prefer to not to have to include
> any cpan libraries...
Why not? I have not yet seen a valid reason.
> no strict;
> if ( open( CONFIG, "$configFile" ) ) {
Don't quote $configFile. This is a FAQ entry:
perldoc -q always
> my $readConfig = "";
No need to initialize.
> while ( <CONFIG> ) { $readConfig .= $_; }
> eval $readConfig;
> %config = %{ $userconfig };
> close( CONFIG );
For effective slurping:
use File::Slurp;
my $readConfig = read_file $configFile;
If, for some unfathomable reason, you are going to avoid File::Slurp,
sub slurp_file {
my ($infile) = @_;
open my $IN, '<', $infile or return;
my $data;
do { local $/; $$data_ref = <$IN> };
close $IN or return;
return \$data;
}
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Sat, 26 Apr 2008 16:17:52 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: untaint a hash eval
Message-Id: <67grskF2ovt1pU1@mid.individual.net>
Ben Bullock wrote:
> On Sat, 26 Apr 2008 11:49:21 +0000, Daniel Parry wrote:
>> I was wondering if anyone could give me some pointers as to the best way
>> to untaint the assocative array %config in the following snippet please?
<snip>
>> if ( open( CONFIG, "$configFile" ) ) {
>> my $readConfig = "";
>> while ( <CONFIG> ) { $readConfig .= $_; } eval $readConfig;
>
> Assuming you actually care about the security of your script, the
> untainting should be done before you "eval" the thing you've read in.
> Otherwise, the above is probably the single most insecure thing you can
> do in a Perl script.
Maybe so, but...
> my $job = <STDIN>;
> print_tainted($job);
> $job =~ /^(.*)$/s;
> $job = $1;
you don't seriously mean that that code would make $job much less
insecure, do you? The regex accepts anything. You'd better choose a
regex that limits the allowed characters as far as possible.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 26 Apr 2008 15:08:19 GMT
From: Daniel Parry <ddp23@cam.ac.uk>
Subject: Re: untaint a hash eval
Message-Id: <slrng16hb3.2hd.ddp23@pip.srcf.ucam.org>
Ben, Gunnar, Sinan,
Many thanks, really appreciate your help!
Best wishes,
Daniel
------------------------------
Date: Sat, 26 Apr 2008 22:11:48 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: untaint a hash eval
Message-Id: <fv09b4$pnm$1@ml.accsnet.ne.jp>
On Sat, 26 Apr 2008 16:17:52 +0200, Gunnar Hjalmarsson wrote:
> Ben Bullock wrote:
>> my $job = <STDIN>;
>> print_tainted($job);
>> $job =~ /^(.*)$/s;
>> $job = $1;
>
> you don't seriously mean that that code would make $job much less
> insecure, do you?
No, I didn't say that. This just removes the taint flag without doing
anything to the string, so there is no absolutely change in security.
It's just a "dodge". Hopefully the original poster understood that, but
thank you for clarifying it.
------------------------------
Date: 27 Apr 2008 00:38:26 GMT
From: xhoster@gmail.com
Subject: Re: untaint a hash eval
Message-Id: <20080426203829.739$vb@newsreader.com>
Daniel Parry <ddp23@cam.ac.uk> wrote:
> Hello all,
>
> I was wondering if anyone could give me some pointers as to the
> best way to untaint the assocative array %config in the following
> snippet please? Do I need to check its content against a suitable
> regexp somehow?
Yes. Without knowing more, we have no idea what regexp would be suitable
for the job.
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: 27 Apr 2008 00:45:39 GMT
From: xhoster@gmail.com
Subject: Re: untaint a hash eval
Message-Id: <20080426204542.648$0N@newsreader.com>
Ben Bullock <benkasminbullock@gmail.com> wrote:
>
> > no strict;
> > if ( open( CONFIG, "$configFile" ) ) {
> > my $readConfig = "";
> > while ( <CONFIG> ) { $readConfig .= $_; } eval $readConfig;
>
> Assuming you actually care about the security of your script, the
> untainting should be done before you "eval" the thing you've read in.
> Otherwise, the above is probably the single most insecure thing you can
> do in a Perl script.
Hardly. It reads and executes some file, presumably from some disk. (He
doesn't show us how that file name was obtained, which is a bit
disconcerting, but anyway...) But what is his initial program itself?
Some file from some disk, most likely. If the evil-doer can put something
malicious in one file on the disk, why can't they put something malicious
into the main file and be done with it? Sure, one could arrange it such
that one of the files is secure and the other isn't, but then again one
could arrange it so that neither file is secure.
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: Sun, 27 Apr 2008 02:09:30 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: untaint a hash eval
Message-Id: <fv0n8q$sev$1@ml.accsnet.ne.jp>
On Sun, 27 Apr 2008 00:45:39 +0000, xhoster wrote:
> Ben Bullock <benkasminbullock@gmail.com> wrote:
>> Assuming you actually care about the security of your script, the
>> untainting should be done before you "eval" the thing you've read in.
>> Otherwise, the above is probably the single most insecure thing you can
>> do in a Perl script.
>
> Hardly. It reads and executes some file, presumably from some disk.
#!/usr/bin/perl
use warnings;
use strict;
my $configFile = "lynx -dump http://www.xhoster.com/some.pl |";
if ( open( CONFIG, "$configFile" ) ) {
my $readConfig = "";
while ( <CONFIG> ) { $readConfig .= $_; }
eval $readConfig;
}
> But what is his initial program itself?
> Some file from some disk, most likely. If the evil-doer can put
> something malicious in one file on the disk, why can't they put
> something malicious into the main file and be done with it?
If the evil-doer has control of the value of $configFile, he can do
anything which the script has the power to do, and the point where the
actual damage occurs is the "eval" statement, not the reading of the file
or opening the file.
> Sure, one
> could arrange it such that one of the files is secure and the other
> isn't, but then again one could arrange it so that neither file is
> secure.
If you can think of anything less secure than eval'ing completely
arbitrary code without checking it, please tell me what it is, otherwise
I'll stick with my initial opinion.
------------------------------
Date: Mon, 28 Apr 2008 08:52:27 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: use of DBI; I am getting multiple error messages mixed in with ?the correct output.
Message-Id: <86y76yb0qc.fsf@mithril.chromatico.net>
>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
PJH> On 2008-04-24 15:46, Ted <r.ted.byers@rogers.com> wrote:
>> And where exactly are you getting the idea that the empty
>> string is a defined null string.
PJH> Common usage. A "null string" is a string of length zero.
Er, this is ambiguous to C programmers: there's a significant
difference between
char *foo = NULL;
and
char *foo = "";
and I would expect that reasonable C programmers would avoid using
"null string" because it's impossible to determine which of the two
the term refers to.
It's also ambiguous in SQL - NULL and '' are different values and can
mean different things.
And hey, it's ambiguous in Perl too - undef and '' are different
values, and can mean different things. The only difference is that
NULL isn't a keyword in Perl, and "null pointer" isn't a useful concept.
PJH> Using the term "null string" instead of "empty string" in a
PJH> thread about DBI is confusing, but since it is quoted from a
PJH> book which is not about DBI or SQL, but about Perl, that's
PJH> just the way it is. You have to learn that English words can
PJH> mean different things depending on context.
I'd side with Ted here, much as the tone of his argument has annoyed
me; there's a valuable distinction between null string and empty
string, even in Perl, and the text of the Camel book is unclear. The
term "null string" for what would more reasonably called an "empty
string" is a mistake. When the Camel is wrong, it should be
corrected, not defended as if it were Holy Writ.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
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 1488
***************************************