[31802] in Perl-Users-Digest
Perl-Users Digest, Issue: 3065 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 21:09:23 2010
Date: Fri, 6 Aug 2010 18:09:08 -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, 6 Aug 2010 Volume: 11 Number: 3065
Today's topics:
Does this match any number or just single digit ones? <thomas@tifozi.net>
Re: Does this match any number or just single digit one <RedGrittyBrick@SpamWeary.invalid>
Re: Does this match any number or just single digit one <tadmc@seesig.invalid>
Re: Extract variable length numbers (tab delimitered) f <wolf@gsheep.com>
Re: Extract variable length numbers (tab delimitered) f <marc.girod@gmail.com>
Re: Extract variable length numbers (tab delimitered) f <uri@StemSystems.com>
Re: Extract variable length numbers (tab delimitered) f <cartercc@gmail.com>
Interix <jak@isp2dial.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <ralph@happydays.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <tzz@lifelogs.com>
Question re calling subroutines HerbF@earthlink.net
Re: Question re calling subroutines <uri@StemSystems.com>
Re: Question re calling subroutines HerbF@earthlink.net
Re: Question re calling subroutines <uri@StemSystems.com>
Re: Question re calling subroutines <tadmc@seesig.invalid>
Re: Question re calling subroutines HerbF@earthlink.net
Re: Question re calling subroutines HerbF@earthlink.net
sysopen failures <marc.girod@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 Aug 2010 22:00:09 +0200
From: "Thomas Andersson" <thomas@tifozi.net>
Subject: Does this match any number or just single digit ones?
Message-Id: <8c37svFqmpU1@mid.individual.net>
Will this line update $page with a number if it's double digit (ie 10+) or
does the code need to change?
my ($page) = $page_number_txt =~ /PAGE (\d) >/;
------------------------------
Date: Fri, 06 Aug 2010 21:16:42 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.invalid>
Subject: Re: Does this match any number or just single digit ones?
Message-Id: <gt6dnS5m3O028MHRnZ2dnUVZ7qGdnZ2d@bt.com>
On 06/08/2010 21:00, Thomas Andersson wrote:
> Will this line update $page with a number if it's double digit (ie 10+) or
No, \d matches a single digit.
> does the code need to change?
Yes. E.g. change \d to \d+
>
> my ($page) = $page_number_txt =~ /PAGE (\d)>/;
>
>
--
RGB
------------------------------
Date: Fri, 06 Aug 2010 16:19:01 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Does this match any number or just single digit ones?
Message-Id: <slrni5out4.ik9.tadmc@tadbox.sbcglobal.net>
Thomas Andersson <thomas@tifozi.net> wrote:
> Will this line update $page with a number if it's double digit (ie 10+) or
> does the code need to change?
>
> my ($page) = $page_number_txt =~ /PAGE (\d) >/;
What happened when you tried it?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 06 Aug 2010 14:01:34 +0200
From: wolf <wolf@gsheep.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <i3gtj8$kb0$02$1@news.t-online.com>
Ted Zlatanov schrieb:
> On Wed, 04 Aug 2010 16:13:38 -0400 Sherm Pendley <sherm.pendley@gmail.com> wrote:
>
> SP> Ted Zlatanov <tzz@lifelogs.com> writes:
>>> So there's value in exploration and cleverness.
>
> SP> Certainly, exploring edge cases is part of the learning process. When
> SP> it comes to production code, though, I find more value in simplicity.
>
> I mean in production too. Today's clever code is tomorrow's standard.
> For example the Guttman Rossler transform at first was clever and
> confusing (I've had to explain it to beginners more than once);
> gradually it became established and today Perl 6 does it internally by
> default.
>
> The threshold IMO is not "is it clever" but "will the maintainer 5 years
> from now hunt me down and kill me if he goes crazy." I thus tend to
> avoid Quantum::Superpositions, on-the-fly parser generators, and "ha ha"
> comments in production code :)
>
> Ted
... and now I find myself learning about sorting algorythms to
understand the answer <G>.
love your comment, ted
cheers, wolf
------------------------------
Date: Fri, 6 Aug 2010 06:32:04 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <1ca1a090-414c-475b-8f54-d66b31b792ff@s9g2000yqd.googlegroups.com>
On Aug 6, 10:25=A0am, Marc Girod <marc.gi...@gmail.com> wrote:
> With all respect due, my own hubris would play Hall against Kernighan.
My name is Wall, Larry Wall...
Marc
------------------------------
Date: Fri, 06 Aug 2010 09:58:22 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <871vabn8qp.fsf@quad.sysarch.com>
>>>>> "w" == wolf <wolf@gsheep.com> writes:
w> Ted Zlatanov schrieb:
>> On Wed, 04 Aug 2010 16:13:38 -0400 Sherm Pendley
>> <sherm.pendley@gmail.com> wrote:
>>
SP> Ted Zlatanov <tzz@lifelogs.com> writes:
>>>> So there's value in exploration and cleverness.
>>
SP> Certainly, exploring edge cases is part of the learning process. When
SP> it comes to production code, though, I find more value in simplicity.
>>
>> I mean in production too. Today's clever code is tomorrow's standard.
>> For example the Guttman Rossler transform at first was clever and
>> confusing (I've had to explain it to beginners more than once);
>> gradually it became established and today Perl 6 does it internally by
>> default.
w> ... and now I find myself learning about sorting algorythms to
w> understand the answer <G>.
it is well documented in Sort::Maker. in fact that module can generate
sorts in four (count'em four!) different styles so you can learn them
all.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 6 Aug 2010 09:18:16 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <3dfba196-0910-42d5-8f29-35350467de1b@z10g2000yqb.googlegroups.com>
On Aug 4, 3:21=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> my head), 40% coding and 20% debugging. and much of the debugging is
> very easy stuff (at least to me). my take on the general coder
> population is like 10% design (if that much), 40% coding and 50%
> debugging. well it seems like that from what i see and hear. debugging
> should be easy IMO if you design the code right. a given bug should be
> quickly isolated to the area that handles that part of data. this brings
> up the design philosophy of high isolation of modules. again, few adhere
> to that idea so they have many places which could cause a given bug
> thereby making debugging harder. i don't use a debugger, IDE or anything
> but print and i get working code without pain. brains over typing! :)
At least part of this depends on the problem domain. The vast majority
of my work depends on user input, and almost all the 'bugs' that make
it past release occur with bad input. For example, an automated
process stopped working one day, and after quite a while debugging, I
took a look at the input data and discovered that a user had set a
password beginning with '#' -- the code skipped all lines as comments
beginning with # so it treated the password as a comment and couldn't
continue because the password field was blank.
It's very difficult to foresee all the ways that users can enter data.
Even if the user is a program you can't necessarily depend on it. I
sometimes get data generated by a database that consolidates blank
fields, which is a problem if you are using split() or a RE to
destructure input data.
Then again, some people don't classify user errors as bugs, but user
errors act just like bugs.
CC.
------------------------------
Date: Fri, 06 Aug 2010 19:32:46 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Interix
Message-Id: <0noo569p1fqp2u6auffteh9k2hm2i3f5s4@4ax.com>
Anyone know if recent Perl tarballs build on Interix 3.5?
--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
------------------------------
Date: Fri, 06 Aug 2010 12:44:28 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <d9724$4c5c3bec$40779ac3$32266@news.eurofeeds.com>
360 lines
2524 words
ha ha ha
The advice for authors for the journal Nature
is almost a 1/4 of this.
Q: Why are these posting guidelines longer than the advice for authors
for one of the world's most prestigious scientific journals?
A: Apserger's related wankery!
So, yeah, tl, dnr.
------------------------------
Date: Fri, 06 Aug 2010 13:00:26 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <87tyn739l1.fsf@lifelogs.com>
On Fri, 06 Aug 2010 12:44:28 -0400 Ralph Malph <ralph@happydays.com> wrote:
RM> 360 lines
RM> 2524 words
RM> ha ha ha
RM> The advice for authors for the journal Nature
RM> is almost a 1/4 of this.
By that logic, saying nothing is very smart. Please take that as a
gentle suggestion.
Ted
------------------------------
Date: Fri, 06 Aug 2010 13:49:33 -0700
From: HerbF@earthlink.net
Subject: Question re calling subroutines
Message-Id: <72to56h22isb2c0ii0vc804slcakg7eghp@4ax.com>
I typically call subroutines without using parenthesis, e.g., &abc;. I
have one routine where I pass variables and I call it as:
&abc(A,B,C);:
sub abc {
$A = $_[0]; B=$_[1]; C=$_[2];
}
Should I be using parenthesis at the subroutine, i.e.,
sub abc (A,B,C) {...}
and why?
TIA,
Herb
------------------------------
Date: Fri, 06 Aug 2010 16:55:31 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Question re calling subroutines
Message-Id: <8739ur5um4.fsf@quad.sysarch.com>
>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
H> I typically call subroutines without using parenthesis, e.g., &abc;. I
H> have one routine where I pass variables and I call it as:
that is poor perl code and perl4 style. don't use & for sub calls as it
has side effects you may not know about. read perldoc perlsub for more.
H> Should I be using parenthesis at the subroutine, i.e.,
H> sub abc (A,B,C) {...}
that has nothing to do with parens at the sub call itself. perl doesn't
support named arguments like you have there so it won't do any good to
try it.
sub calls should be made with parens is the common style rule and not
with &.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 06 Aug 2010 14:01:13 -0700
From: HerbF@earthlink.net
Subject: Re: Question re calling subroutines
Message-Id: <drto56p491bdt51p5ert4j5pouhivj51im@4ax.com>
Uri Guttman wrote:
>>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
>
> H> I typically call subroutines without using parenthesis, e.g., &abc;. I
> H> have one routine where I pass variables and I call it as:
>
>that is poor perl code and perl4 style. don't use & for sub calls as it
>has side effects you may not know about. read perldoc perlsub for more.
>
> H> Should I be using parenthesis at the subroutine, i.e.,
>
> H> sub abc (A,B,C) {...}
>
>that has nothing to do with parens at the sub call itself. perl doesn't
>support named arguments like you have there so it won't do any good to
>try it.
>
>sub calls should be made with parens is the common style rule and not
>with &.
>
Thanks. Do I understand you to say that &abc; is "wrong" and that I should
be using abc(); instead?
As I'm calling one routine as &abc(A,B,C); what is the correct syntax?
Herb
------------------------------
Date: Fri, 06 Aug 2010 17:17:22 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Question re calling subroutines
Message-Id: <878w4j4f19.fsf@quad.sysarch.com>
>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
>> sub calls should be made with parens is the common style rule and not
>> with &.
H> Thanks. Do I understand you to say that &abc; is "wrong" and that I
H> should be using abc(); instead?
yes. i just said that. so do the docs. please read them as that is the
best way to learn perl. there is a whole doc just for perl subs.
H> As I'm calling one routine as &abc(A,B,C); what is the correct syntax?
no, drop the & as it is NOT NEEDED nor desirable. it marks your coding
style as ancient perl4ish. it can cause issues you don't know about.
parens are all you need and are correct.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 06 Aug 2010 16:28:05 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Question re calling subroutines
Message-Id: <slrni5ove4.ik9.tadmc@tadbox.sbcglobal.net>
HerbF@earthlink.net <HerbF@earthlink.net> wrote:
> Uri Guttman wrote:
>
>>>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
>>
>> H> I typically call subroutines without using parenthesis, e.g., &abc;. I
>> H> have one routine where I pass variables and I call it as:
>>
>>that is poor perl code and perl4 style. don't use & for sub calls as it
>>has side effects you may not know about. read perldoc perlsub for more.
>>
>> H> Should I be using parenthesis at the subroutine, i.e.,
>>
>> H> sub abc (A,B,C) {...}
>>
>>that has nothing to do with parens at the sub call itself. perl doesn't
>>support named arguments like you have there so it won't do any good to
>>try it.
What you have there is called a "prototype", they are often a Bad Idea,
so you shouldn't be using them at all.
If what you want is named arguments, then you typically do that by
copying the args in the first statement in the subroutine body:
sub abc {
my($A, $B, $C) = @_;
...
But don't choose one-letter variable names!
>>sub calls should be made with parens is the common style rule and not
>>with &.
>>
> Thanks. Do I understand you to say that &abc; is "wrong" and that I should
> be using abc(); instead?
Yes.
> As I'm calling one routine as &abc(A,B,C); what is the correct syntax?
abc(A,B,C);
perldoc -q difference
What's the difference between calling a function as &foo and foo()?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 06 Aug 2010 15:13:21 -0700
From: HerbF@earthlink.net
Subject: Re: Question re calling subroutines
Message-Id: <b72p56dt62825bv5u540a8pfp5ngkf0ph0@4ax.com>
Uri Guttman wrote:
>>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
>
> >> sub calls should be made with parens is the common style rule and not
> >> with &.
>
> H> Thanks. Do I understand you to say that &abc; is "wrong" and that I
> H> should be using abc(); instead?
>
>yes. i just said that. so do the docs. please read them as that is the
>best way to learn perl. there is a whole doc just for perl subs.
>
> H> As I'm calling one routine as &abc(A,B,C); what is the correct syntax?
>
>no, drop the & as it is NOT NEEDED nor desirable. it marks your coding
>style as ancient perl4ish. it can cause issues you don't know about.
>parens are all you need and are correct.
>
Thank you.
HF
------------------------------
Date: Fri, 06 Aug 2010 15:14:07 -0700
From: HerbF@earthlink.net
Subject: Re: Question re calling subroutines
Message-Id: <582p56t0jj2r11u52lqf731r6jr174ut95@4ax.com>
Tad McClellan wrote:
>HerbF@earthlink.net <HerbF@earthlink.net> wrote:
>> Uri Guttman wrote:
>>
>>>>>>>> "H" == HerbF <HerbF@earthlink.net> writes:
>>>
>>> H> I typically call subroutines without using parenthesis, e.g., &abc;. I
>>> H> have one routine where I pass variables and I call it as:
>>>
>>>that is poor perl code and perl4 style. don't use & for sub calls as it
>>>has side effects you may not know about. read perldoc perlsub for more.
>>>
>>> H> Should I be using parenthesis at the subroutine, i.e.,
>>>
>>> H> sub abc (A,B,C) {...}
>>>
>>>that has nothing to do with parens at the sub call itself. perl doesn't
>>>support named arguments like you have there so it won't do any good to
>>>try it.
>
>
>What you have there is called a "prototype", they are often a Bad Idea,
>so you shouldn't be using them at all.
>
>If what you want is named arguments, then you typically do that by
>copying the args in the first statement in the subroutine body:
>
> sub abc {
> my($A, $B, $C) = @_;
> ...
>
>But don't choose one-letter variable names!
Of course. :-)
>
>
>>>sub calls should be made with parens is the common style rule and not
>>>with &.
>>>
>> Thanks. Do I understand you to say that &abc; is "wrong" and that I should
>> be using abc(); instead?
>
>
>Yes.
>
>
>> As I'm calling one routine as &abc(A,B,C); what is the correct syntax?
>
>
>abc(A,B,C);
>
>
> perldoc -q difference
>
> What's the difference between calling a function as &foo and foo()?
Thanks very much.
Herb
------------------------------
Date: Fri, 6 Aug 2010 10:06:46 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: sysopen failures
Message-Id: <f48c93e5-a89a-4994-8ca4-620280ad1754@c10g2000yqi.googlegroups.com>
Hello,
A script saves mails sent by a crontab--so, there may be bursts...
It uses sysopen, I assume to make sure it doesn't overwrite existing
files.
At times, we get bursts of errors (File exists), which I trace to the
sysopen call.
However, I cannot find that all the corresponding files would have
existed.
I read the doc and get to:
In many systems the "O_EXCL" flag is available for opening
files
in exclusive mode. This is not locking: exclusiveness
means here
that if the file already exists, sysopen() fails. "O_EXCL"
may
not work on network filesystems, and has no effect unless
the
"O_CREAT" flag is set as well.
The script does write to a network filesystems (home directory on a
remote filer, 4 ms round-trip).
Shoud I look for a replacement for sysopen?
Or for an other theory to explain the problem?
The bit of code doing the open:
if(defined($mode)? sysopen(FILE, $file, O_EXCL | O_CREAT | O_WRONLY,
$mode):
sysopen(FILE, $file, O_EXCL | O_CREAT | O_WRONLY))
{
_dump(*FILE, @$r_lines);
return close(FILE);
}
return(0);
Thanks,
Marc
------------------------------
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 3065
***************************************