[31896] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3159 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 2 09:09:24 2010

Date: Sat, 2 Oct 2010 06:09:06 -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           Sat, 2 Oct 2010     Volume: 11 Number: 3159

Today's topics:
    Re: Claimed to be an "old hack" (David Canzi)
    Re: Need Regex for phone number <thegist@nospam.net>
    Re: Need Regex for phone number <stanley@peak.org>
    Re: Need Regex for phone number <tadmc@seesig.invalid>
    Re: Need Regex for phone number <hjp-usenet2@hjp.at>
    Re: why does this happen? <jurgenex@hotmail.com>
    Re: why does this happen? <merrilljensen@q.com>
    Re: why does this happen? <tadmc@seesig.invalid>
    Re: why does this happen? <mvdwege@mail.com>
    Re: why does this happen? <hjp-usenet2@hjp.at>
    Re: why does this happen? <npeelman@cfl.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 1 Oct 2010 20:54:13 +0000 (UTC)
From: dmcanzi@remulak.uwaterloo.ca (David Canzi)
Subject: Re: Claimed to be an "old hack"
Message-Id: <i85hpl$ja6$1@rumours.uwaterloo.ca>

In article <707an7-jp62.ln1@osiris.mauzo.dyndns.org>,
Ben Morrow  <ben@morrow.me.uk> wrote:
>
>Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
>> On 2010-09-28, Ben Morrow <ben@morrow.me.uk> wrote:
>> >> >> {(!($^O=~/^[M]*$32/i)&&($0=~s!^.*/!!))||($0=~s!.*\\!!)}
>> 
>> >> > Making that correction, we have an expression of
>> >> > the form
>> >> >
>> >> >     (A && B) || C
>> >> >
>> >> > which is a nasty shorthand for
>> >> >
>> >> >     if (A) {
>> >> >         B
>> >> >     }
>> >> >     else {
>> >> >         C
>> >> >     }
>> >> 
>> >> No, it is not.
>> >
>> > I know it's not *equivalent*. But, in this case, that *is* how it's
>> > being used.
>> 
>> Unclear.  It looks like you wanted it mean something like "B never
>> fails", so C cannot be executed if A succeeds (which is not true), and
>> you "nasty" is just for "using ||/&& for control flow" (which I also
>> won't agree with).
>
>I don't have a big problem with using || and && for control flow. I
>think it's a little ugly, but not importantly so.

I've been thinking lately about what happens when somebody else
reads my code and learns from it.

I spent a lot of time in the last couple of years untying code
knots created by a co-worker.  I saw one particularly offensive
piece of code and recognized it as something he probably learned
from reading my code.

When people see code like "A && B || C" being used as if it's
equivalent to the if-else construct you wrote above, they're
too likely to think it's really neat, and not likely enough to
notice that it's dependent on B always being true.  And they'll
go on to write incorrect code using this trick.  And somebody
else will have to spend time debugging it.

-- 
David Canzi		| "We are here on Earth to fart around.
			| Don't let anybody tell you any different."
			| -- Kurt Vonnegut


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

Date: Fri, 01 Oct 2010 16:36:08 -0400
From: "thegist@nospam.net" <thegist@nospam.net>
Subject: Re: Need Regex for phone number
Message-Id: <141c7$4ca64638$ce534406$2862@news.eurofeeds.com>

On 10/1/2010 3:39 PM, Ted Zlatanov wrote:
> My personal favorite interview (as an applicant) was at ITA software.
> "Sit down, here's a computer.  Write a program in 30 minutes to do X.
> We'll come back."
Was the problem they asked you a toy problem like this phone number
thing, a tricky puzzle, something else?
What did they expect you to do in 30 minutes?


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

Date: Fri, 1 Oct 2010 13:42:54 -0700
From: John Stanley <stanley@peak.org>
Subject: Re: Need Regex for phone number
Message-Id: <alpine.LRH.2.00.1010011302570.21404@shell.peak.org>

On Fri, 1 Oct 2010, Charlton Wilbur wrote:

> Indeed.  I'd love to see Mr. Stanley's response to some of the requests
> I've gotten from our sysadmins or our marketing department.
>
> I'm sure they'd relish being yammered at

If they considered a discussion about exactly what they wanted "being 
yammered at", well, that's their problem. It seems to be your problem, 
too.

I've never had a customer refuse to discuss the requirements or more fully 
describe a bug or error report when asked. Never. Most of them seem 
truly happy that I'm interested enough in exactly what their 
problem is so that I can give them what they need and not just what 
they ask for.

Perhaps your system admins and marketing team are used to your style of 
operations and just drop sticky notes on your desk and run. Must be fun to 
work there. Not.

> because they didn't use a
> particular term in the idiosyncratic sense he prefers,

If by "idiosyncratic sense" you mean "as defined by various international 
standards", then, well, ok. Fair cop. I assume that technical people who 
use technical terms know what they mean. When they come out of the mouths 
of marketers, however, I don't. I "yammer at" them to find out what they 
really want. (I've yet to find one that says "stop yammering and just 
write what I said".)

> or because they
> used a different term in a clarification and he can't find it in himself
> to reconcile the two.

Tell me, in your system, what is the result of a "reconcilliation" of one 
spec that says "you must validate the area code", and another that comes 
later that says "remove the requirement to validate, just make sure it is 
well-formed". I'm truly curious about that.




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

Date: Fri, 01 Oct 2010 15:57:00 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Need Regex for phone number
Message-Id: <slrniacirf.gi7.tadmc@tadbox.sbcglobal.net>

thegist@nospam.net <thegist@nospam.net> wrote:

> What did they expect you to do in 30 minutes?


Save 30% on car insurance?


-- 
Rest In Peace: 
Jonah McClellan gave his life for his country in a
helicopter crash in Afghanistan on September 21,2010.
Please pray for his wife and three children.


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

Date: Sat, 2 Oct 2010 09:54:46 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Need Regex for phone number
Message-Id: <slrniadpa7.uc2.hjp-usenet2@hrunkner.hjp.at>

On 2010-09-30 21:30, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
>  PJH> On 2010-09-30 19:00, Charlton Wilbur <cwilbur@chromatico.net> wrote:
>  >>>>>>> "UG" == Uri Guttman <uri@StemSystems.com> writes:
>  UG> it isn't about knowing phone numbers or styles, it is a basic
>  UG> simple parsing question that any decent perl hacker should be
>  UG> able to do. 
>  >> 
>  >> Precisely.  It's a toy problem that any competent Perl programmer should
>  >> be able to come up with a reasonable solution to within 10 minutes.
>
>  PJH> The problem is that there are way too many programmers which then take
>  PJH> their solution to your "toy problem" and apply it to the real world.
>  PJH> There are a lot of registration forms which require a phone number as a
>  PJH> mandatory field but don't accept my phone number because it it has too
>  PJH> few or too many digits or I have formatted it differently than the
>  PJH> programmer expected (and of course he doesn't tell me what he expects -
>  PJH> he just tells me "please enter a valid phone number" and deletes the
>  PJH> other 20 fields I have already entered. There are also forms which don't
>  PJH> accept email addresses with a "+" in the local part, or punctuation in a
>  PJH> house number. And so on.
>
> you are missing the point. it is NOT a real world problem. it is just an
> exercise given during an interview. it is meant to see HOW the candidate
> solves a problem and thinks about it.

Right. What we disagree about is what answers we expect. You and Wilbur
expect the interviewee to say "All right, that's easy. A phone number is
always 10 digits and the first three are the area code. Plus there may
be some interpunctation characters (dash, blank, parentheses), so I'll
just hack together a regex for that". I expect the interviewee to say
"That's hard. A phone number could be local, long distance or
international. Both country and area prefixes can be variable length and
there seem to be no generic rules. Plus, those rules change over time,
so even if we get it right now, it's probably wrong next year. So we
have to think about how we can maintain them. And anyway what do you
want with an area code when most people are using cellphones?" Or
something like that. If an interviewee assumes that his local phone
number scheme is all there is and immediately start coding, I'd flunk
him for not thinking things through.

Of course you can always turn it into a simple programming question by
adding restrictions. For example something like this:

    We have phone numbers from several sources. We know all of them are
    US numbers (or at least they should be), but they are formatted
    differently [list of possible formats here or ask the interviewee to
    provide one].  We want to get them all into a common format
    [description here]. Write a program which converts them all into
    this format and writes those which cannot be converted to a
    different file for later inspection.


> good questions about formats are a plus.

IMO they aren't a plus, they are absolutely required.

> not even being able to code up a basic simple parser for a basic
> number is bad.

The problem which you refuse to see is that outside of the US there is
no "simple parser for a basic number". And implicitely assuming that
local conventions are universal is a very bad trait in a programmer. The
examples I provided were real, and they were not from the website of a
grocery store somewhere in the midwest - they were from large,
international companies, who apparently employed programmers who
couldn't think beyond their own nose - programmers who would answer
Wilburs question the way you and Wilbur want, but who are utterly
incompetent for their job.

> this thread is crazy. charlton knows the difference between real world
> and interview.

Maybe he does but I think he filters for the wrong skills. But maybe
he's looking for code monkeys, not programmers.

	hp



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

Date: Fri, 01 Oct 2010 18:54:11 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: why does this happen?
Message-Id: <t04da6h6svtd4b94457jovl3fg842bm9qr@4ax.com>

Uno <merrilljensen@q.com> wrote:
>Jürgen Exner wrote:
>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>> under a new name from your editor? 
>> That would be very, very different from renaming an existing file, i.e.
>> from what you claimed you were doing before.
>> 
>>> So when I rename perl2.pl to perl3.pl, this is what I get:
>
>Yeah.  I was really tripped by the permissions not being the same from 
>saving with gedit.

It is a new file! New! Not a renamed file.
Why would it inherit it's permissions from some other arbitrary file
only because they happen to have similar names?

>Ben Bacarisse from clc once recommended something called emacs.
>What is that?

comp.[...].editors.emacs is over that way there.

jue


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

Date: Fri, 01 Oct 2010 20:16:04 -0600
From: Uno <merrilljensen@q.com>
Subject: Re: why does this happen?
Message-Id: <8gniv5Fg10U1@mid.individual.net>

Jürgen Exner wrote:
> Uno <merrilljensen@q.com> wrote:
>> Jürgen Exner wrote:
>>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>>> under a new name from your editor? 
>>> That would be very, very different from renaming an existing file, i.e.
>>> from what you claimed you were doing before.
>>>
>>>> So when I rename perl2.pl to perl3.pl, this is what I get:
>> Yeah.  I was really tripped by the permissions not being the same from 
>> saving with gedit.
> 
> It is a new file! New! Not a renamed file.
> Why would it inherit it's permissions from some other arbitrary file
> only because they happen to have similar names?

What it means to me is that I want a new development environment. Btw, 
"it's" is a contracting for "it is."  The third person neuter possessive 
in english is "its."

It's the exception to the rule.
> 
>> Ben Bacarisse from clc once recommended something called emacs.
>> What is that?
> 
> comp.[...].editors.emacs is over that way there.

I'm looking through the tutorial now and know that I don't want to 
memorize a bunch of control characters again.
-- 
Uno


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

Date: Fri, 01 Oct 2010 22:12:48 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: why does this happen?
Message-Id: <slrniad8s5.hfg.tadmc@tadbox.sbcglobal.net>

["Followup-To:" header set to comp.lang.perl.misc.]

Uno <merrilljensen@q.com> wrote:
> Jürgen Exner wrote:
>> Uno <merrilljensen@q.com> wrote:
>>> Jürgen Exner wrote:
>>>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>>>> under a new name from your editor? 


>>> Yeah.  I was really tripped by the permissions not being the same from 
>>> saving with gedit.


>> It is a new file! New! Not a renamed file.
>> Why would it inherit it's permissions from some other arbitrary file
>> only because they happen to have similar names?


vi has the same behavior as gedit, ie. no execute permission
on new files.


> What it means to me is that I want a new development environment.


No, you simply need a new development _process_.

If you know before the edit session that you'll want a new name,
then cp (copy) it, which preserves the permissions:

   cp rm1.f90 rm2.f90
   gedit rm2.f90

then use "Save" rather than "Save As" after you've made your edits.


>>> Ben Bacarisse from clc once recommended something called emacs.


I am of the vi religion.

Can some heretic of the emacs religion tell us if emacs behaves
the same as vi and gedit?

That is, when you write a file with a new name in emacs, does
it preserve file permissions?


-- 
Rest In Peace: 
Jonah McClellan gave his life for his country in a
helicopter crash in Afghanistan on September 21,2010.
Please pray for his wife and three children.


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

Date: Sat, 02 Oct 2010 10:03:25 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: why does this happen?
Message-Id: <86iq1lvx6a.fsf@gareth.avalon.lan>

Tad McClellan <tadmc@seesig.invalid> writes:

> ["Followup-To:" header set to comp.lang.perl.misc.]
>
> Uno <merrilljensen@q.com> wrote:
>> Jürgen Exner wrote:
>>> Uno <merrilljensen@q.com> wrote:
>>>> Jürgen Exner wrote:
>>>>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>>>>> under a new name from your editor? 
>
>
>>>> Yeah.  I was really tripped by the permissions not being the same from 
>>>> saving with gedit.
>
>
>>> It is a new file! New! Not a renamed file.
>>> Why would it inherit it's permissions from some other arbitrary file
>>> only because they happen to have similar names?
>
>
> vi has the same behavior as gedit, ie. no execute permission
> on new files.
>
>
>> What it means to me is that I want a new development environment.
>
>
> No, you simply need a new development _process_.
>
> If you know before the edit session that you'll want a new name,
> then cp (copy) it, which preserves the permissions:
>
>    cp rm1.f90 rm2.f90
>    gedit rm2.f90
>
> then use "Save" rather than "Save As" after you've made your edits.
>
Or he learns how to use a version control system.

After all, what he is doing now is manual version control. That's error
prone and tedious, precisely the thing to automate.

I prefer git, it's lightweight and fairly easy to learn:

1. 'git init' in your project directory.

2. 'git add <files>' to add the files you want to track (I often do a
   'git add *' on my initial files)

3. 'git commit' and type your commit message.

Then, just after every major change, just 'git commit' again.


>
>>>> Ben Bacarisse from clc once recommended something called emacs.
>
>
> I am of the vi religion.
>
> Can some heretic of the emacs religion tell us if emacs behaves
> the same as vi and gedit?
>
> That is, when you write a file with a new name in emacs, does
> it preserve file permissions?

Emacs heretic here. No it doesn't.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


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

Date: Sat, 2 Oct 2010 10:13:50 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: why does this happen?
Message-Id: <slrniadqe4.uc2.hjp-usenet2@hrunkner.hjp.at>

On 2010-10-02 01:54, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Uno <merrilljensen@q.com> wrote:
>>Jürgen Exner wrote:
>>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>>> under a new name from your editor? 
>>> That would be very, very different from renaming an existing file, i.e.
>>> from what you claimed you were doing before.
>>> 
>>>> So when I rename perl2.pl to perl3.pl, this is what I get:
>>
>>Yeah.  I was really tripped by the permissions not being the same from 
>>saving with gedit.
>
> It is a new file! New! Not a renamed file.

ACK.

> Why would it inherit it's permissions from some other arbitrary file
> only because they happen to have similar names?

Actually, if you use an editor to open file "A", possibly edit it, and
then save it as "B", I don't think it is entirely unreasonable to assume
that B will have the same permissions as A. A is not "some other
arbitrary file with a similar name", it is an older version of B, and
the editor knows it, so it could set the permissions of B to match those
of A. I don't know any editor which does this, and I've never missed the
capability, but now that I think about it, this seems like a good thing
to me.

	hp



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

Date: Sat, 02 Oct 2010 07:06:11 -0400
From: Norman Peelman <npeelman@cfl.rr.com>
Subject: Re: why does this happen?
Message-Id: <4ca71224$0$14858$9a6e19ea@unlimited.newshosting.com>

Uno wrote:
> Jürgen Exner wrote:
>> Uno <merrilljensen@q.com> wrote:
>>> Jürgen Exner wrote:
>>>> So, let me rephrase that: Are you saying, you are _SAVING_ the file
>>>> under a new name from your editor? That would be very, very 
>>>> different from renaming an existing file, i.e.
>>>> from what you claimed you were doing before.
>>>>
>>>>> So when I rename perl2.pl to perl3.pl, this is what I get:
>>> Yeah.  I was really tripped by the permissions not being the same 
>>> from saving with gedit.
>>
>> It is a new file! New! Not a renamed file.
>> Why would it inherit it's permissions from some other arbitrary file
>> only because they happen to have similar names?
> 
> What it means to me is that I want a new development environment.

   It's permissions, it's always permissions... when things like this 
appear to not be working - check permissions. It's a security feature.


 > Btw, "it's" is a contracting for "it is."  The third person neuter 
possessive
> in english is "its."
> 
> It's the exception to the rule.
>>

OH boy, here we go again...

>>> Ben Bacarisse from clc once recommended something called emacs.
>>> What is that?
>>
>> comp.[...].editors.emacs is over that way there.
> 
> I'm looking through the tutorial now and know that I don't want to 
> memorize a bunch of control characters again.


-- 
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 8.04 64bit


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3159
***************************************


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