[28109] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9473 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 14 18:10:18 2006

Date: Fri, 14 Jul 2006 15:10:10 -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           Fri, 14 Jul 2006     Volume: 10 Number: 9473

Today's topics:
        matching only alphabetic chars and only digits with per <jack_posemsky@yahoo.com>
    Re: matching only alphabetic chars and only digits with <someone@example.com>
    Re: matching only alphabetic chars and only digits with <no@email.com>
        Perl and Politics ilikesluts@gmail.com
    Re: Perl and Politics <sherm@Sherm-Pendleys-Computer.local>
    Re: Perl and Politics anno4000@radom.zrz.tu-berlin.de
    Re: Perl and Politics <1usa@llenroc.ude.invalid>
    Re: Perl and Politics ilikesluts@gmail.com
    Re: Perl and Politics ilikesluts@gmail.com
    Re: RegEx and AND <No_4@dsl.pipex.com>
    Re: Traverse a directory <weberw@adelphia.net>
    Re: Traverse a directory <weberw@adelphia.net>
    Re: What is a type error? <eval.apply@gmail.com>
    Re: What is a type error? <jo@durchholz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 14 Jul 2006 14:38:40 -0700
From: "Jack" <jack_posemsky@yahoo.com>
Subject: matching only alphabetic chars and only digits with periods
Message-Id: <1152913120.070466.240470@m79g2000cwm.googlegroups.com>

Hi I am trying to match ONLY alphabetic chars (not digits or anything
else)..

I am finding that

$temp = '14.5a';
	if ($temp =~ m/\D+/ and $temp !~ m/\d+/) { print " alpha "; }

Only matches NONDIGITS...    ?  # . is a non digit but not alphabetic..
how do I test for pure alphabetic ?

Likewise, how do I test for pure numeric dollar amount with a "period"
in them "."- the following doesnt work since the Not equal excludes "."
off the bat..
$temp = '14.5a';
if ($temp =~ m/\d+/ and $temp  !~ m/\D+/ and $temp =~ m/\.{1}/) { print
" digit DOT "; }

Any slick ways to change this specific code and keep it simple ?
Thank you,
Jack



------------------------------

Date: Fri, 14 Jul 2006 21:48:47 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: matching only alphabetic chars and only digits with periods
Message-Id: <3jUtg.135458$S61.126871@edtnps90>

Jack wrote:
> Hi I am trying to match ONLY alphabetic chars (not digits or anything
> else)..

$ perl -le'print "a3#b7&C9(D.>" =~ /[[:alpha:]]/g'
abCD
$ perl -le'print "a3#b7&C9(D.>" =~ /[^\W\d_]/g'
abCD



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Fri, 14 Jul 2006 22:52:17 +0100
From: Brian Wakem <no@email.com>
Subject: Re: matching only alphabetic chars and only digits with periods
Message-Id: <4hqi0hFsb2iU1@individual.net>

Jack wrote:

> Hi I am trying to match ONLY alphabetic chars (not digits or anything
> else)..
> 
> I am finding that
> 
> $temp = '14.5a';
> if ($temp =~ m/\D+/ and $temp !~ m/\d+/) { print " alpha "; }
> 
> Only matches NONDIGITS...    ?  # . is a non digit but not alphabetic..
> how do I test for pure alphabetic ?


m/^[a-zA-Z]+$/


> Likewise, how do I test for pure numeric dollar amount with a "period"
> in them "."- the following doesnt work since the Not equal excludes "."
> off the bat..
> $temp = '14.5a';
> if ($temp =~ m/\d+/ and $temp  !~ m/\D+/ and $temp =~ m/\.{1}/) { print
> " digit DOT "; }


m/^\d+\.\d{2}$/


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


------------------------------

Date: 14 Jul 2006 12:24:48 -0700
From: ilikesluts@gmail.com
Subject: Perl and Politics
Message-Id: <1152905087.255227.63450@i42g2000cwa.googlegroups.com>

Hi Everyone,

I was wondering if the perl community shares common political beliefs,
if so what are they?



------------------------------

Date: Fri, 14 Jul 2006 16:31:56 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Perl and Politics
Message-Id: <m2hd1k9bcz.fsf@Sherm-Pendleys-Computer.local>

ilikesluts@gmail.com writes:

> Hi Everyone,
>
> I was wondering if the perl community shares common political beliefs,
> if so what are they?

I now believe that you are a troll. I think you'll find that belief is now
quite common here. Goodbye. *plonk*

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: 14 Jul 2006 20:32:16 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Perl and Politics
Message-Id: <4hqdagFrji2U1@news.dfncis.de>

 <ilikesluts@gmail.com> wrote in comp.lang.perl.misc:
> Hi Everyone,
> 
> I was wondering if the perl community shares common political beliefs,
> if so what are they?

One consensus would be that trolls are assholes.

Anno


------------------------------

Date: Fri, 14 Jul 2006 20:39:37 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl and Politics
Message-Id: <Xns9800A993079CCasu1cornelledu@127.0.0.1>

anno4000@radom.zrz.tu-berlin.de wrote in news:4hqdagFrji2U1
@news.dfncis.de:

>  <ilikesluts@gmail.com> wrote in comp.lang.perl.misc:
>> Hi Everyone,
>> 
>> I was wondering if the perl community shares common political beliefs,
>> if so what are they?
> 
> One consensus would be that trolls are assholes.

AOL ;-)

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://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: 14 Jul 2006 13:48:13 -0700
From: ilikesluts@gmail.com
Subject: Re: Perl and Politics
Message-Id: <1152910093.628268.311190@m79g2000cwm.googlegroups.com>

Hi Sherm,

You always thought I was a troll, so what exactly has changed "now"?

Sherm Pendle wrote:
"I should have known you're a troll and just ignored
you instead of answering. I won't be making *that* mistake again... "



Sherm Pendley wrote:
> ilikesluts@gmail.com writes:
>
> > Hi Everyone,
> >
> > I was wondering if the perl community shares common political beliefs,
> > if so what are they?
>
> I now believe that you are a troll. I think you'll find that belief is now
> quite common here. Goodbye. *plonk*
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net



------------------------------

Date: 14 Jul 2006 13:58:55 -0700
From: ilikesluts@gmail.com
Subject: Re: Perl and Politics
Message-Id: <1152910735.435850.84200@m73g2000cwd.googlegroups.com>

Hi Anno,
I don't like trolls either but I can't help but think that you are
suggesting that I am a troll.  Is that what you saying?  If so please
be forthright and straight forward.  I think that being straight
forward is the basis of good communications and good communications
goes a long way to reducing troll like behaviors on message boards.

anno4000@radom.zrz.tu-berlin.de wrote:
> One consensus would be that trolls are assholes.
> 
> Anno



------------------------------

Date: Fri, 14 Jul 2006 20:58:36 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: RegEx and AND
Message-Id: <q86dne4zF7PzairZRVny1w@pipex.net>

anno4000@radom.zrz.tu-berlin.de wrote:

>              The Perl programmer's way of saying "$string contains
> 'tree' somewhere" is
> 
>     $string =~ /tree/;

    However, if you are looking for the *word* "tree" (rather than, say, 
"streetwise") you'll need:

  $string =~ /\btree\b/;



-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


------------------------------

Date: 14 Jul 2006 14:56:19 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: Re: Traverse a directory
Message-Id: <1152914179.346070.185980@i42g2000cwa.googlegroups.com>

Tad-    return if /folder 3/; still included the files inside the
folder 3 so it didn't work.  It did exclude folder 3 but the contents
of folder 3 were displayed.



------------------------------

Date: 14 Jul 2006 15:03:43 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: Re: Traverse a directory
Message-Id: <1152914623.265443.4470@p79g2000cwp.googlegroups.com>

Paul-thanks for the tips of posting guidelines.  Wasn't aware of this
before.  Anyway.  I tried the skip dir that you mentioned and
unfortunately it does skip the folder but still includes the contents
of the folder.  
Paul Lalli



------------------------------

Date: 14 Jul 2006 12:46:37 -0700
From: "Joe Marshall" <eval.apply@gmail.com>
Subject: Re: What is a type error?
Message-Id: <1152906397.860152.312910@m73g2000cwd.googlegroups.com>


Marshall wrote:
> Joe Marshall wrote:
> > Marshall wrote:
> > >
> > > Consider the following Java fragment:
> > >
> > > void foo() {
> > >   int i = 0;
> > >   int j = 0;
> > >
> > >   // put any code here you want
> > >
> > >   j = 1;
> > >   i = 2;
> > >   // check value of j here. It is still 1, no matter what you filled in
> > > above.
> > >   // The assignment to i cannot be made to affect the value of j.
> > >
> > > }
> >
> > True, but you have hidden the pointers.  Semantically, the identifiers
> > i and j refer not to integers but to locations that hold integers.  The
> > assignment modifies the location.
>
> What the implementation looks like shouldn't affect how we speak
> of the logical model. In the above code, there are no pointers.
>
> By your definition, "pointer" and "variable" are synonyms. That doesn't
> seem like a good idea to me. (What if i and j end up in registers?
> I have not heard it said that registers have addresses.)

You probably won't like this, but....

The example you give above is a bit ambiguous as to whether or not it
shows `true' mutation.  So what do I mean by `true' mutation?  The code
above could be transformed by alpha-renaming into an equivalent version
that does no mutation:

void foo() {
   int i = 0;
   int j = 0;

   // put any code here you want

   int jj = 1;
   int ii = 2;
   // rename all uses of i to ii and j to jj after this point.

 }

Once I've done the renaming, we're left with a pure function.  I claim
that this sort of `mutation' is uninteresting because it can be
trivially eliminated through renaming.  Since we can eliminate it
through renaming, we can use a simplified semantics that does not
involve a `store', and use a substitution model of evaluation.

The more interesting kind of mutation cannot be eliminated through
renaming.  The semantic model requires the notion of a stateful
`store', and the model is not referentially transparent: substitution
does not work.  These qualities are what make mutation problematic.  My
claim is that this kind of mutation cannot be had without some model of
pointers and references.

There is a further distinguishing characteristic:  Can I write a
program that detects the mutation (and acts differently depending on
whether there is mutation or not)?  It is unclear from your example
above whether you intended this to be possible, but certainly there is
no way for a caller of foo to tell that foo reassigns an internal
variable.  If there a procedure is extrinsically a pure function, then
there is no real meaning to any `mutation' that goes on inside; there
is always a way to turn the internal mutation into a pure function
through alpha-renaming.

>
> Clearly there is *some* difference between a language which allows
> explicit pointers and thus aliasing and one that doesn't. What term
> would you use? First-class variables?

My argument to you in re this statement:
> Again, I disagree: it is posible to have mutability without
> pointers/identity/objects.

is that mutability without a notion of pointers, identity, or objects
is trivially eliminated through alpha renaming and thus isn't the
`mutability' of interest.



------------------------------

Date: Fri, 14 Jul 2006 23:43:25 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e993et$jvr$1@online.de>

Marshall schrieb:
> Joachim Durchholz wrote:
>> Marshall schrieb:
>>> What about my example of SQL? Mutation, no pointers, no aliasing.
>>> Yet: useful.
>> Sorry, but SQL does have aliasing.
> 
> Well. I suppose we do not have an agreed upon definition
> of aliasing, so it is hard to evaluate either way. I would
> propose using the same one you used for identity:
> 
> if there are two variables and modifying one also modifies
> the other, then there is aliasing between them.

I think that's an adequate example.
For a definition, I'd say it's a bit too narrow unless we use a fairly 
broad definition for "variable". I.e. in a C context, I'd say that a->b 
is a variable, too, as would be foo(blah)->x.

> I avoided mentioning equality to include, for example,
> having an array i that is an alias to a subset of array j.

This would mean that there's aliasing between, say, a list of 
transaction records and the balance of the account (since modifying the 
list of transactions will change the balance, unless the object isn't 
properly encapsulated).
For purposes of this discussion, it's probably fair to say "that's a 
form of aliasing, too", even though it's quite indirect.

>> E.g. if you have records that have name="John", surname="Doe", the
>> statements
>>    SELECT * FROM persons WHERE name = "John"
>> and
>>    SELECT * FROM persons WHERE name = "Doe"
>> are aliases of each other.

Arrrrrgh... I made a most braindamaged, stupid mistake here. The second 
SELECT should have used the *surname* field, so it would be

 >>    SELECT * FROM persons WHERE surname = "Doe"

Then, if there's a record that has name = "John", surname = "Doe", the 
two WHERE clauses have aliasing in the form of overlapping result sets.

>> The alias is actually in the WHERE clause.
> 
> Not by my definition, because there is only one variable here.

Sorry, my wording was sloppy.

I meant to say that 'in SQL, you identify records via clauses like WHERE 
name = "John", i.e. WHERE clauses are a kind of identity'.

This is still not precise - the identity of an SQL record isn't 
explicitly accessible (except the nonstandard OID facility that some SQL 
engines offer). Nevertheless, they do have an identity, and there's a 
possibility of aliasing - if you change all Johns, you may also change a 
Doe.

>> And this *can* get you into
>> trouble if you have something that does
>>    UPDATE ... WHERE name = "John"
>> and
>>    UPDATE ... WHERE surname = "Doe"
>> e.g. doing something with the Johns, then updating the names of all
>> Does, and finally restoring the Johns (but not recognizing that changing
>> the names of all Does might have changed your set of Johns).
> 
> The fact that some person might get confused about the
> semantics of what they are doing does not indicate aliasing.
> It is easy enough to do an analysis of your updates and
> understand what will happen; this same analysis is impossible
> with two arbitrary pointers, unless one has a whole-program
> trace. That strikes me as a significant difference.

Sure. I said that aliases in SQL aren't as bad as in other programs.

Once you get abstraction mixed in, the analysis becomes less 
straightforward. In the case of SQL, views are such an abstraction 
facility, and they indeed can obscure what you're doing and make the 
analysis more difficult. If it's just SQL we're talking about, you 
indeed have to look at the whole SQL to check whether there's a view 
that may be involved in the queries you're analysing, so the situation 
isn't *that* different from pointers - it's just not a problem because 
the amount of code is so tiny!

>> Conceptually, this is just the same as having two different access path
>> to the same memory cell. Or accessing the same global variable through a
>> call-by-reference parameter and via its global name.
> 
> There are similarities, but they are not the same.

What are the relevant differences? How does the semantics of a WHERE 
clause differ from that of a pointer, in terms of potential aliasing?

My line of argument would be this:
Pointers can be simulated using arrays, so it's no surprise that arrays 
can emulate all the aliasing of pointers.
Arrays can be simulated using WHERE (with SELECT and UPDATE), so I'd say 
that SQL can emulate all the aliasing of arrays, and hence that of pointers.

>> BTW with views, you get not just aliasing but what makes aliasing really
>> dangerous. Without views, you can simply survey all the queries that you
>> are working with and lexically compare table and field names to see
>> whether there's aliasing. With views, the names that you see in a
>> lexical scope are not enough to determine aliasing.
>> E.g. if you use a view that builds upon the set of Johns but aren't
>> aware of that (possibly due to abstraction barriers), and you change the
>> name field of all Does, then you're altering the view without a chance
>> to locally catch the bug. That's just as bad as with any pointer
>> aliasing problem.
> 
> It is certainly aliasing, but I would not call it "just as bad." There
> are
> elaborate declarative constraint mechanisms in place, for example.

Yes, but they can give you unexpected results.
It smells a bit like closing the gates after the horses are out.

On the other hand, *if* there is identity and updates, no matter how we 
handle them, there must be *some* way to deal with the problems that 
ensue. Having declarative constraints doesn't sound like the worst way 
to do that.

> And the definition of the view itsef is a declarative, semantic
> entity. Whereas a pointer is an opaque, semantics-free address.

Oh, that's a very BCPL view. It was still somewhat true for K&R C, but 
it's not really applicable to ANSI C, not at all to C++, and even less 
to languages that associate well-encapsulated types with pointers (such 
as Ada, Eiffel, or Java).
Unless, of course, you mean "address" if you say "pointer" ;-)

Regards,
Jo


------------------------------

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 9473
***************************************


home help back first fref pref prev next nref lref last post