[30936] in Perl-Users-Digest
Perl-Users Digest, Issue: 2181 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 4 03:09:41 2009
Date: Wed, 4 Feb 2009 00:09:06 -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 Wed, 4 Feb 2009 Volume: 11 Number: 2181
Today's topics:
Re: ++ Hilary Clinton Sex Scandal albundy2@mailinator.com
Re: Can't figure this code out <larry@example.invalid>
Re: Extracting printf(...) from (void) printf(....) sln@netherlands.com
new CPAN modules on Wed Feb 4 2009 (Randal Schwartz)
Re: Perl Peeves (Tim McDaniel)
Re: Perl Peeves <hjp-usenet2@hjp.at>
Re: Perl Peeves <hjp-usenet2@hjp.at>
Re: Perl Peeves sln@netherlands.com
Regular Expression Help? <valid@email.address>
Re: Regular Expression Help? <tim@burlyhost.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Feb 2009 18:45:06 -0800 (PST)
From: albundy2@mailinator.com
Subject: Re: ++ Hilary Clinton Sex Scandal
Message-Id: <bf479765-6d13-45ac-877a-89234d1c53d8@q30g2000prq.googlegroups.com>
On Feb 3, 2:26 am, systemofadownsyndr...@gmail.com wrote:
> The video that rocked the
> oval oralfis , Hilary Clinton Sex tape naked with The hockey legend
> Wade Greatski..
Yea, must be the great Wade Greatski taking it to the hole once again.
He's trying to break Wilbur Chamberlain's record.
If it were real, I'd pay dearly not to see it.
------------------------------
Date: Tue, 3 Feb 2009 21:35:56 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: Can't figure this code out
Message-Id: <dl4ww17lg6u4.s5qbgz8rkjys.dlg@40tude.net>
On Mon, 02 Feb 2009 19:49:25 -0500, Charlton Wilbur wrote:
>>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:
>
> TJM> Why did you set followups to comp.lang.c?
>
> comp.lang.c is suffering an assault from an asshat troll who's figured
> out how to forge posts. Its latest tactic is to forge inane questions
> in other groups in the name of comp.lang.c regulars and set followups to
> comp.lang.c.
>
> Charlton
Ben is one of the persons I'll chat with in clc. I try to avoid the word
"troll" on usenet, although I do use it frequently for the clientele I see
at Walmart. clc's in an unusual state of chaos. The inmates are running
the asylum.
I just don't want it to spread to groups I really like. I'd be pissed if
some teenager screwed up usenet for me by such impersonations.
It's also ironic that the troll (Han from chine) who "broke through" and
has commanded respect by being right when, eg Heathfield, is not, is also
not the troll who's doing the latest string of forgeries.
--
larry gates
I dunno. Perhaps you should be happy that I have a policy of refraining
from grumbling about handicapped operating systems. :-)
-- Larry Wall in <199808291719.KAA12244@wall.org>
------------------------------
Date: Tue, 03 Feb 2009 22:37:32 GMT
From: sln@netherlands.com
Subject: Re: Extracting printf(...) from (void) printf(....)
Message-Id: <l4hho4hiipm4oum7eigj3gndlt9ejgb704@4ax.com>
On Mon, 2 Feb 2009 20:31:45 -0800 (PST), guru <guru.naveen@gmail.com> wrote:
>On Feb 2, 10:12 pm, s...@netherlands.com wrote:
>> On Mon, 02 Feb 2009 16:54:19 GMT, s...@netherlands.com wrote:
>> >On Mon, 2 Feb 2009 06:04:50 -0800 (PST), guru <guru.nav...@gmail.com> wrote:
>>
>> >>HI all
>>
>> >>How to search for (void) from the line.
>>
>> [snip]
>> >and be mixed with comments. A better solution is to get a C++ parser somewhere.
>>
>> >But, if this isn't real source code text and all you want to do is parse anything
>> >in (void) "function(anything)" on a line by line basis, I guess you could adopt a quick and
>> >dirty approach, something like this:
>>
>> >while (<DATA>) # no caching of lines, raw per-line basis
>> >{
>> > chomp;
>> > if (/(\s*void\s*)\s*([a-z][\w-]*?\s*\(.*\)\s*)/ { # greedy () in liue of balanced parenthesis
>>
>> ^^^
>> I forgot to mention this is untested. After looking at it a bit, this may be better:
>>
>> /\(\s*void\s*\)\s*([a-zA-Z][\w-]*\s*\(.*\))/
>>
>> Gee, there are alot of paren's in this one..
>>
>> sln- Hide quoted text -
>>
>> - Show quoted text -
>
>HI
>
>yes this is not a real example.
>
>the acually the pattern will be of type
>
>1. (void) function(....)
>2. function(....)
>3. return (function(....)........)
>
>I want to extract the function(....) from the above type of lines.
>
>Thanks & Regards
>Gururaja
Oh, I needed something to do for a few hours.
I guess the below should parse C/C++ functions any way desired.
sln
---------------------------------------------------------
## Idea - To parse out C/C++ style functions
## that have parenthetical closures (some don't)
## ===============================================
use strict;
use warnings;
my $Source = join '', <DATA>;
my @Funct = (); # Holds sequential functions info;
# ie: substr indexes to 'name', '(', and ')' segment positions
my @Ndx = (); # Index stack of current @Funct elements in find recursion
my $Preamble = "\\s*\\("; # constant
my $Compliance = "_*[a-zA-Z][\\w]*"; # constant
my $FName = $Compliance; # Gets all functions, uses the compliant pattern
#my $FName = "\\(\\s*void\\s*\\)\\s*function"; # Extended, non-compliant function pattern
# ***************************************
# Or, uncomment these to search for a specific function name that is compliant.
# (Warning! FName should resolve to a compliant function name)
# If you wish to use a custom regex for FName (non-compliant), skip this block and enter FName above.
# -------------------------
# my $FName = "atoi";
# die "Function name pattern: '$FName' is non-compliant!\n" if ($FName !~ /$Compliance/);
# ***************************************
# The main pre-compiled parser regular expression
my $FxParse = qr/(\/{2}.*?\n)|(\/\*.*?\*\/)|($FName$Preamble)|(\()|(\))/s;
# 1 1|2 2|3 3|4 4|5 5
# Parse out some functions
Find_Function(\$Source);
# Print functions found
if (!@Funct) { print "Function name pattern: '$FName' not found!\n" }
else { print "\nFound ".@Funct." matches.\nFunction pattern: '$FName' \n" }
for my $ref (@Funct)
{
# print "@{$ref}\n";
print "\n\@: ";
print substr($Source,$ref->[0],$ref->[2]-$ref->[0]),"\n";
# Here, each function name and/or parameter can be printed
# and/or examined separately.
}
# Finished!
#
# ---------------------------------------------------------
# Recursive procedure that finds C/C++ style functions
# (the engine)
#
sub Find_Function
{
my ($src,$spos,$closure) = @_;
$spos = 0 if (!defined $spos);
$closure = 0 if (!defined $closure);
pos($$src) = $spos;
while ($$src =~ /$FxParse/g)
{
# $1/$2 - comments
if (defined $3) # 'function name'
{
push @Ndx, scalar(@Funct);
# positions: function ( )
push @Funct , [$-[0], pos($$src), 0];
# recurse this procedure
pos($$src) = Find_Function ( $src, pos($$src), 1 );
}
elsif (defined $4) # '('
{
++$closure;
}
elsif (defined $5) # ')'
{
--$closure;
if ($closure <= 0)
{
if (@Ndx)
{
$Funct[pop @Ndx]->[2] = pos($$src);
return pos($$src);
}
$closure = 0;
}
}
}
}
__DATA__
1. (void) function(....)
2. function(....)
3. return ( // some comments
function(..(atoi("398"), (5 * x)..)..,
/* ) <-forget this parenth */......)
)
---------------------------------------------
Do not copy from here down...
---------------------------------------------
Some various input/output:
c:\temp>perl c_functionparser.pl
Found 5 matches.
Function pattern: '_*[a-zA-Z][\w]*'
@: function(....)
@: function(....)
@: return ( // some comments
function(..(atoi("398"), (5 * x)..)..,
/* ) <-forget this parenth */......)
)
@: function(..(atoi("398"), (5 * x)..)..,
/* ) <-forget this parenth */......)
@: atoi("398")
c:\temp>
----------------------------
c:\temp>perl c_functionparser.pl
Found 3 matches.
Function pattern: 'function'
@: function(....)
@: function(....)
@: function(..(atoi("398"), (5 * x)..)..,
/* ) <-forget this parenth */......)
c:\temp>
---------------------------
c:\temp>perl c_functionparser.pl
Found 1 matches.
Function pattern: 'atoi'
@: atoi("398")
c:\temp>
---------------------------
c:\temp>perl c_functionparser.pl
Found 1 matches.
Function pattern: '\(\s*void\s*\)\s*function'
@: (void) function(....)
c:\temp>
------------------------------
Date: Wed, 4 Feb 2009 05:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Feb 4 2009
Message-Id: <KEJ16q.1JC8@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.
Apache2-ASP-2.24
http://search.cpan.org/~johnd/Apache2-ASP-2.24/
ASP for Perl, reloaded.
----
Apache2-Controller-1.000.100
http://search.cpan.org/~markle/Apache2-Controller-1.000.100/
fast MVC-style Apache2 handler apps
----
B-Hooks-OP-Annotation-0.01
http://search.cpan.org/~chocolate/B-Hooks-OP-Annotation-0.01/
Annotate and delegate hooked OPs
----
Big5Plus-0.32
http://search.cpan.org/~ina/Big5Plus-0.32/
"Yet Another JPerl" Source code filter to escape Big5Plus
----
Catalyst-Authentication-Store-Tangram-0.008
http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Tangram-0.008/
A storage class for Catalyst authentication from a class stored in Tangram
----
Catalyst-View-TT-ForceUTF8-0.13
http://search.cpan.org/~lyokato/Catalyst-View-TT-ForceUTF8-0.13/
(DEPRECATED) Template View Class with utf8 encoding
----
CatalystX-CMS-0.002
http://search.cpan.org/~karman/CatalystX-CMS-0.002/
drop-in content management system
----
Class-Sniff-0.06
http://search.cpan.org/~ovid/Class-Sniff-0.06/
Look for class composition code smells
----
Config-Model-OpenSsh-1.203
http://search.cpan.org/~ddumont/Config-Model-OpenSsh-1.203/
OpenSsh configuration files editor
----
Crypt-FSHP-0.2.3
http://search.cpan.org/~bdd/Crypt-FSHP-0.2.3/
Fairly Secure Hashed Passwords. A PKCS#5 PBKDF1 similar implementation.
----
DBIx-Class-InflateColumn-Object-Enum-0.04
http://search.cpan.org/~jmmills/DBIx-Class-InflateColumn-Object-Enum-0.04/
Allows a DBIx::Class user to define a Object::Enum column
----
Data-Pareto-0.01
http://search.cpan.org/~pwes/Data-Pareto-0.01/
Computing Pareto sets in Perl
----
Data-ParseBinary-0.2
http://search.cpan.org/~semuelf/Data-ParseBinary-0.2/
Yet Another parser for binary structures
----
Devel-NYTProf-2.07_95
http://search.cpan.org/~timb/Devel-NYTProf-2.07_95/
Powerful feature-rich perl source code profiler
----
EBook-Tools-0.4.0
http://search.cpan.org/~azed/EBook-Tools-0.4.0/
Object class for manipulating and generating E-books
----
Finance-Bank-mBank-0.01
http://search.cpan.org/~bjakubski/Finance-Bank-mBank-0.01/
Check mBank account balance
----
GBK-0.32
http://search.cpan.org/~ina/GBK-0.32/
"Yet Another JPerl" Source code filter to escape GBK
----
Geo-GML-0.14
http://search.cpan.org/~markov/Geo-GML-0.14/
Geography Markup Language processing
----
Geo-IPfree-0.5
http://search.cpan.org/~bricas/Geo-IPfree-0.5/
Look up country of IP Address. This module make this off-line and the DB of IPs is free & small.
----
Git-CPAN-Patch-0.1.1
http://search.cpan.org/~yanick/Git-CPAN-Patch-0.1.1/
Patch CPAN modules using Git
----
HTML-MobileJpCSS-0.02
http://search.cpan.org/~komoriya/HTML-MobileJpCSS-0.02/
css inliner and converter
----
HTTP-MobileAttribute-0.13
http://search.cpan.org/~tokuhirom/HTTP-MobileAttribute-0.13/
Yet Another HTTP::MobileAgent
----
MIME-Types-1.27
http://search.cpan.org/~markov/MIME-Types-1.27/
Definition of MIME types
----
Mail-Box-2.087
http://search.cpan.org/~markov/Mail-Box-2.087/
manage a mailbox, a folder with messages
----
MediaWiki-Bot-2.1.0
http://search.cpan.org/~dcollins/MediaWiki-Bot-2.1.0/
a Wikipedia bot framework written in Perl
----
Module-Install-0.79
http://search.cpan.org/~adamk/Module-Install-0.79/
Standalone, extensible Perl module installer
----
Moose-0.66
http://search.cpan.org/~drolsky/Moose-0.66/
A postmodern object system for Perl 5
----
MooseX-Constructor-AllErrors-0.001
http://search.cpan.org/~hdp/MooseX-Constructor-AllErrors-0.001/
capture all constructor errors
----
MooseX-Constructor-AllErrors-0.002
http://search.cpan.org/~hdp/MooseX-Constructor-AllErrors-0.002/
capture all constructor errors
----
MooseX-Constructor-AllErrors-0.003
http://search.cpan.org/~hdp/MooseX-Constructor-AllErrors-0.003/
capture all constructor errors
----
MooseX-Emulate-Class-Accessor-Fast-0.00800
http://search.cpan.org/~groditi/MooseX-Emulate-Class-Accessor-Fast-0.00800/
Emulate Class::Accessor::Fast behavior using Moose attributes
----
Net-FTPSSL-0.06
http://search.cpan.org/~cleach/Net-FTPSSL-0.06/
A FTP over SSL/TLS class
----
Net-SCP-Expect-0.15
http://search.cpan.org/~rybskej/Net-SCP-Expect-0.15/
Wrapper for scp that allows passwords via Expect.
----
ORDB-CPANTS-0.02
http://search.cpan.org/~adamk/ORDB-CPANTS-0.02/
An ORM for the published CPANTS SQLite database
----
ORDB-CPANTesters-0.04
http://search.cpan.org/~adamk/ORDB-CPANTesters-0.04/
An ORM for the published CPAN Testers SQLite database
----
ORLite-1.19
http://search.cpan.org/~adamk/ORLite-1.19/
Extremely light weight SQLite-specific ORM
----
ORLite-Mirror-1.10
http://search.cpan.org/~adamk/ORLite-Mirror-1.10/
Extend ORLite to support remote SQLite databases
----
ORLite-Mirror-1.11
http://search.cpan.org/~adamk/ORLite-Mirror-1.11/
Extend ORLite to support remote SQLite databases
----
PAR-Dist-FromCPAN-1.10
http://search.cpan.org/~smueller/PAR-Dist-FromCPAN-1.10/
Create PAR distributions from CPAN
----
PAR-Indexer-0.91
http://search.cpan.org/~smueller/PAR-Indexer-0.91/
Scan a PAR distro for packages and scripts
----
POE-Component-SmokeBox-0.10
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.10/
POE enabled CPAN smoke testing with added value.
----
Parallel-SubArray-0.1
http://search.cpan.org/~sizur/Parallel-SubArray-0.1/
Forked sub execution with return values and timeouts.
----
Parallel-SubArray-0.3
http://search.cpan.org/~sizur/Parallel-SubArray-0.3/
Execute forked subref array and join return values, timeouts and error captures.
----
Parallel-SubArray-0.3.1
http://search.cpan.org/~sizur/Parallel-SubArray-0.3.1/
Execute forked subref array and join return values, timeouts and error captures.
----
Parallel-SubArray-0.3002
http://search.cpan.org/~sizur/Parallel-SubArray-0.3002/
Execute forked subref array and join return values, timeouts and error captures.
----
Parallel-SubArray-0.4001
http://search.cpan.org/~sizur/Parallel-SubArray-0.4001/
Execute forked subref array and join return values, timeouts and error captures.
----
Parallel-SubArray-0.4002
http://search.cpan.org/~sizur/Parallel-SubArray-0.4002/
Execute forked subref array and join return values, timeouts and error captures.
----
RTx-Tags-0.12
http://search.cpan.org/~jpierce/RTx-Tags-0.12/
Tag Cloud support for RT with simple-searchable custom fields.
----
Roguelike-Utils-0.4.250
http://search.cpan.org/~earonesty/Roguelike-Utils-0.4.250/
----
SVN-Class-0.12
http://search.cpan.org/~karman/SVN-Class-0.12/
manipulate Subversion workspaces with Perl objects
----
Set-Relation-0.3.0
http://search.cpan.org/~duncand/Set-Relation-0.3.0/
Relation data type for Perl
----
Simo-0.05_05
http://search.cpan.org/~kimoto/Simo-0.05_05/
Very simple framework for Object Oriented Perl.
----
Sjis-0.32
http://search.cpan.org/~ina/Sjis-0.32/
"Yet Another JPerl" Source code filter to escape ShiftJIS
----
Statistics-Basic-1.6002
http://search.cpan.org/~jettero/Statistics-Basic-1.6002/
A collection of very basic statistics modules
----
String-TagString-0.001
http://search.cpan.org/~rjbs/String-TagString-0.001/
----
String-TagString-0.002
http://search.cpan.org/~rjbs/String-TagString-0.002/
----
String-Urandom-0.07
http://search.cpan.org/~mbrooks/String-Urandom-0.07/
Generate a truly random string
----
Sub-Information-0.10
http://search.cpan.org/~ovid/Sub-Information-0.10/
Get subroutine information
----
Test-Apocalypse-0.03
http://search.cpan.org/~apocal/Test-Apocalypse-0.03/
Apocalypse's favorite tests bundled into a simple interface
----
Test-HTML-Form-0.01
http://search.cpan.org/~teejay/Test-HTML-Form-0.01/
HTML Testing and Value Extracting
----
Test-MockDBI-0.64
http://search.cpan.org/~aff/Test-MockDBI-0.64/
Mock DBI interface for testing
----
Test-Weaken-1.003_000
http://search.cpan.org/~jkegl/Test-Weaken-1.003_000/
Test that freed references are, indeed, freed
----
Test-Weaken-1.003_001
http://search.cpan.org/~jkegl/Test-Weaken-1.003_001/
Test that freed references are, indeed, freed
----
Time-Progress-1.4
http://search.cpan.org/~cade/Time-Progress-1.4/
Elapsed and estimated finish time reporting.
----
UHC-0.32
http://search.cpan.org/~ina/UHC-0.32/
"Yet Another JPerl" Source code filter to escape UHC
----
WWW-Freshmeat-0.03
http://search.cpan.org/~chorny/WWW-Freshmeat-0.03/
automates searches on Freshmeat.net
----
WebService-MusicBrainz-0.21
http://search.cpan.org/~bfaist/WebService-MusicBrainz-0.21/
----
forks-0.29
http://search.cpan.org/~rybskej/forks-0.29/
drop-in replacement for Perl threads using fork()
----
jaipo-0.0.7
http://search.cpan.org/~bluet/jaipo-0.0.7/
----
jpgresize-0.3.1-beta
http://search.cpan.org/~fgoslich/jpgresize-0.3.1-beta/
----
mpp-11
http://search.cpan.org/~pfeiffer/mpp-11/
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: Tue, 3 Feb 2009 22:01:51 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Perl Peeves
Message-Id: <gmaesf$5fv$1@reader1.panix.com>
In article <4987b2d5$0$194$e4fe514c@news.xs4all.nl>,
Hans Mulder <hansmu@xs4all.nl> wrote:
>Your expectations are off: unary - does not always take the numerical
>value of its argument:
>
>$ perl -lwe '$x="blah"; print -$x;'
>-blah
>
>Perldoc perlop describes what unary - does with string arguments.
Thank you for that information. I didn't know that either. The Perl
5.00502 man page explanation:
Unary "-" performs arithmetic negation if the operand is
numeric. If the operand is an identifier, a string consisting
of a minus sign concatenated with the identifier is returned.
Otherwise, if the string starts with a plus or minus, a string
starting with the opposite sign is returned. One effect of
these rules is that -bareword is equivalent to the string
"-bareword". If, however, the string begins with a non-
alphabetic character (exluding "+" or "-"), Perl will attempt
to convert the string to a numeric and the arithmetic negation
is performed. If the string cannot be cleanly converted to a
numeric, Perl will give the warning 'Argument "the string"
isn't numeric in negation (-) at ....'
--
Tim (that's peeve #8) McDaniel, tmcd@panix.com
------------------------------
Date: Tue, 3 Feb 2009 23:26:05 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Perl Peeves
Message-Id: <slrngohh3v.trt.hjp-usenet2@hrunkner.hjp.at>
On 2009-02-02 18:53, sln@netherlands.com <sln@netherlands.com> wrote:
> On Sun, 01 Feb 2009 16:24:08 GMT, Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>>Peter J. Holzer wrote:
>>> I said !0 is the same thing as 1 which means, that
>>>
>>> if (a == !0)
>>>
>>> is exactly the same as
>>>
>>> if (a == 1)
>>>
>>> While
>>>
>>> if (a)
>>>
>>> is the same thing as
>>>
>>> if (a != 0)
>>>
>>> Obviously (a != 0) and (a == 1) are not the same thing.
> ^^^^^ ^^^^^
> I know you mean this in the context stated above, but it looks funny
> when put together this way.
> In fact, if a is equal to 1, then (a != 0) == (a == 1) is true.
Also if a is equal to 0.
But if (a != 0) and (a == 1) were the same thing it would have to be
true for all possible values of a. So let's try it with a == 2:
(2 != 0) == 1
(2 == 1) == 0
1 is not equal to zero, therefore (a != 0) is not the same as (a == 1).
QED.
hp
------------------------------
Date: Tue, 3 Feb 2009 23:50:26 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Perl Peeves
Message-Id: <slrngohihj.trt.hjp-usenet2@hrunkner.hjp.at>
On 2009-02-03 14:59, Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
> Uri Guttman wrote:
>>>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
>> PJH> Who said I don't like it? I never said such a thing. I don't even
>> think PJH> it is very complex. The number 0, the strings '' and '0' and
>> the undef PJH> value are false, all other scalars are true.
>>
>> i agree this is a simple and clear rule. why people fuss over it, i
>> don't know. let perl be perl. forcing a specific value to be the one
>> 'true' false (sic :) is a waste of time and anal. it is like normalizing
>> for no reason and it bloats the code. even the concept of using the
>> result of a boolean test for its numeric or string value bothers me. a
>> boolean test value (of any kind in any lang) should only be used in a
>> boolean context. anything else is a slippery shortcut that makes the
>> code more complex and harder to read.
>
> That's basically where I'm coming from - I have an immediate cringe when I
> see the result of a test being used as an int.
I find this odd from someone who claims to have an extensive background
in assembler and early C programming. After all, in machine code
everything is just bits. And early C had inherited quite a bit (no pun
intended) from that mindset, if mostly via its typeless predecessors
BCPL and B.
> I find it odd that
> normalization of bool results is built into the compiler,
What "normalization of bool results is built into the compiler"?
> just so it can be used in an integer context.
> I also find that insisting that !0 = 1 is weird.
That's just what the ! operator is defined as in C. It is an integer
function which returns 1 if its argument is zero, and 0 otherwise.
In mathematical terms it is the Kronecker delta function with one
argument (and C's == operator is the Kronecker delta function with two
arguments).
> As a statement of english it's obviously false
In English, it is just a syntax error. The exclamation point comes at
the end of a sentence, not the beginning ;-).
As a statement about the operator "!" in the programming language C it
is not obviously false, but provably true.
> and in the context of a programming language is simply a side-effect
> of the above mentioned normalisation being applied to a unary logical
> operator
You make the mistake of assuming a-priory that there must be such a
thing as a "logical" or "boolean" type. C has no such thing. The
operators !, ==, <, &&, etc. all return results of type int.
(1 == 1) does not return "true", it returns "1", just like the Ī“(1,1)
returns 1. You may not like that, but that's the way it is in C.
> and not useful in itself.
I find it very useful that operators built into the language returned a
defined result. If anything, C has too many "implementation defined" and
"undefined" corners for my taste.
hp
------------------------------
Date: Wed, 04 Feb 2009 00:02:12 GMT
From: sln@netherlands.com
Subject: Re: Perl Peeves
Message-Id: <oelho454qkdhsndo7vnvjvnk35qlstu225@4ax.com>
On Tue, 3 Feb 2009 23:26:05 +0100, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2009-02-02 18:53, sln@netherlands.com <sln@netherlands.com> wrote:
>> On Sun, 01 Feb 2009 16:24:08 GMT, Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>>>Peter J. Holzer wrote:
>>>> I said !0 is the same thing as 1 which means, that
>>>>
>>>> if (a == !0)
>>>>
>>>> is exactly the same as
>>>>
>>>> if (a == 1)
>>>>
>>>> While
>>>>
>>>> if (a)
>>>>
>>>> is the same thing as
>>>>
>>>> if (a != 0)
>>>>
>>>> Obviously (a != 0) and (a == 1) are not the same thing.
>> ^^^^^ ^^^^^
>> I know you mean this in the context stated above, but it looks funny
>> when put together this way.
>> In fact, if a is equal to 1, then (a != 0) == (a == 1) is true.
>
>Also if a is equal to 0.
>
>But if (a != 0) and (a == 1) were the same thing it would have to be
>true for all possible values of a. So let's try it with a == 2:
>
>(2 != 0) == 1
>(2 == 1) == 0
>
>1 is not equal to zero, therefore (a != 0) is not the same as (a == 1).
>
>QED.
>
> hp
Nobody said anything about being true for all possible values of a.
Using that logic, if expression (a != 0) is not the same as (a == 1) then
it would be true for all possible values of a.
Since {0,1} satisfy the condition of (a != 0) == (a == 1) as true, the
answer is that (a != 0) is the same as (a == 1) sometimes, and not at other times.
Elementary quantim physics.
sln
------------------------------
Date: Wed, 4 Feb 2009 13:03:07 +0900
From: "Trespasser" <valid@email.address>
Subject: Regular Expression Help?
Message-Id: <49891376$0$18792$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
Hi,
I can appreciate what a wonderfully powerful tool regular expressions are,
but I am still learning and seem to need a little help.
I have an example of a regular expression for an Apache server mod_rewrite
module rewrite trigger condition.
^www.\.[^.]+\.domain\.com$
As far as I can gather this is supposed to match www.username.domain.com,
where 'username' could be any system user's username or other alphanumeric
character sequence.
Can anyone please tell me how I can modify this type of regular expression
as follows? I want the rule to match for sequences like username.domain.com
and otherusername.domain.com, but specifically not to match for
www.domain.com.
I would so appreciate it if somebody could please lend me some of their
valuable expertise to help solve my dilemma.
Regards,
Tressie.
------------------------------
Date: Tue, 03 Feb 2009 20:12:12 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Regular Expression Help?
Message-Id: <xA8il.1918$ml6.1098@newsfe09.iad>
Trespasser wrote:
> Hi,
>
> I can appreciate what a wonderfully powerful tool regular expressions
> are, but I am still learning and seem to need a little help.
>
> I have an example of a regular expression for an Apache server
> mod_rewrite module rewrite trigger condition.
>
> ^www.\.[^.]+\.domain\.com$
You probably don't want ^www.\., but ^www\. instead.
> As far as I can gather this is supposed to match
> www.username.domain.com, where 'username' could be any system user's
> username or other alphanumeric character sequence.
>
> Can anyone please tell me how I can modify this type of regular
> expression as follows? I want the rule to match for sequences like
> username.domain.com and otherusername.domain.com, but specifically not
> to match for www.domain.com.
What about domain.com? Will you want to be matching
www.something.example.com, still as well?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
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 2181
***************************************