[32146] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3411 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 13 14:09:27 2011

Date: Mon, 13 Jun 2011 11: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           Mon, 13 Jun 2011     Volume: 11 Number: 3411

Today's topics:
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
    Re: [RegEx] Optional parameter (Randal L. Schwartz)
    Re: [RegEx] Optional parameter <uri@StemSystems.com>
    Re: Module for parsing .authinfo? <tzz@lifelogs.com>
    Re: Regex Matching sln@netherlands.com
    Re: Regex Matching <rweikusat@mssgmbh.com>
    Re: require statement <ac.russell@live.com>
    Re: The Forthcoder Diaries -- 2011 June 9 sln@netherlands.com
    Re: Unicode labels with Chart::Composite <*@eli.users.panix.com>
    Re: Warning in one statement, not in apparently identic sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 13 Jun 2011 00:48:44 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87vcwaipb7.fsf@sapphire.mobileactivedefense.com>

Charlton Wilbur <cwilbur@chromatico.net> writes:
>>>>>> "RW" == Rainer Weikusat <rweikusat@mssgmbh.com> writes:
>
>     RW> you assert that I "wouldn't care about my code or data". This is
>     RW> at least a grave insult and given that I do use warnings, it is
>     RW> essentially a lie you published about me. And knowingly making
>     RW> false statements about others in public in order to damage their
>     RW> reputation (as much as possible) is ... well ... libel.
>
> Someone threatens a libel suit over opinions expressed on Usenet!

Someone apparently can't read here. 

[...]

> And yes, uri, there are places that will hire programmers with abysmally
> bad coding practices.  If Herr Weikusat is looking for work and persists
> in his attitude that he knows better than anyone else possibly can,

I've since spend a little more thought on this: The purpose of
'warnings' and 'stricture' is to help developers debug their perl
code. I have used (and do use) languages whose debugging support
features are significantly poorer than that of present versions of
Perl5, notably, the Bourne shell language an PL/Pgsql (and
older versions of Perl5), extensivlely. Consequently, I'm capable of
debugging my code without warnings, use strict and the Perl debugger,
if need be (although I prefer using all three of them insofar I'm
lucky enough to have them available). Taking this into account, "Mr
Uri's" statement essentially reduces to 'the company I am affliated
with would never hire someone competent enough to write a non-trivial
shell script that actually works'.

And this is certainly good to know.


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

Date: Sun, 12 Jun 2011 17:11:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: [RegEx] Optional parameter
Message-Id: <86boy2mvz5.fsf@red.stonehenge.com>

>>>>> "Rainer" == Rainer Weikusat <rweikusat@mssgmbh.com> writes:

Rainer> I've since spend a little more thought on this: The purpose of
Rainer> 'warnings' and 'stricture' is to help developers debug their perl
Rainer> code.

I'm with you there.  I'm actually of the camp that "use warnings" does
more harm than good for the expert programmer.  Sadly, there aren't
enough experts out here. :)

-- 
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.posterous.com/ for Smalltalk discussion


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

Date: Sun, 12 Jun 2011 20:27:26 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87hb7ueftd.fsf@quad.sysarch.com>

>>>>> "RW" == Rainer Weikusat <rweikusat@mssgmbh.com> writes:

  RW> I've since spend a little more thought on this: The purpose of
  RW> 'warnings' and 'stricture' is to help developers debug their perl
  RW> code. I have used (and do use) languages whose debugging support
  RW> features are significantly poorer than that of present versions of
  RW> Perl5, notably, the Bourne shell language an PL/Pgsql (and
  RW> older versions of Perl5), extensivlely. Consequently, I'm capable of
  RW> debugging my code without warnings, use strict and the Perl debugger,
  RW> if need be (although I prefer using all three of them insofar I'm
  RW> lucky enough to have them available). Taking this into account, "Mr
  RW> Uri's" statement essentially reduces to 'the company I am affliated
  RW> with would never hire someone competent enough to write a non-trivial
  RW> shell script that actually works'.

nope. you don't get it. first off, i am an independent agent who places
perl developers, i don't work for anyone else. see perlhunter.com for
more. as such, i am relied upon to review perl coders before i decide to
submit them to a client. given your attitude, i wouldn't submit you to
any of my clients (even though some would possibly hire you). as for
debugging, let me know when you have debugged programs in PL/I on punch
cards with 2 hours between batch runs and only a printout of your
results. or debugged a standalong rtos in assembler with no outside
access to a running system. then you can claim some skills in
debugging. you haven't proven anything. undef warnings are very useful
and code should be warnings clean at all times. even for undef. as i
said i have one module on cpan where i turn off undef warnings in one
specific place where it is very advantageous. the difference is i chose
the local spot to do that and not let undef values fly all over the
place potentially causing harm.

so get it into your head. this isn't libel (and you are very dumb to say
that). i wouldn't place you not because of the undef warnings thing but
because of how you defend it (poorly at that). a good defense of a
coding style is admirable to me. a weak and wrong defense and not seeing
that when shown many times is just bad.

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: Mon, 13 Jun 2011 11:24:05 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module for parsing .authinfo?
Message-Id: <871uyx7l96.fsf@lifelogs.com>

On Fri, 10 Jun 2011 23:19:36 -0700 (PDT) brad <brad.clawsie@gmail.com> wrote: 

b> hi! oddly enough i had the problem of parsing .authinfo files crop up
b> recently and i decided to start a File::Authinfo pkg. i should have it
b> done and uploaded to cpan in a few days (hopefully)

b> i will try to accomodate some of the suggestions made here. if people would rather just see this work be folded into Net::Netrc, i can back off

OK with me, my work was still in the "TODO list" stage.

I'll add support for gpg: tokens as a patch once you've put it on CPAN.

Thanks
Ted


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

Date: Sun, 12 Jun 2011 15:39:27 -0700
From: sln@netherlands.com
Subject: Re: Regex Matching
Message-Id: <dgfav6p2gdss5dkiusoh9assp5qokv6r7d@4ax.com>

On Sat, 11 Jun 2011 16:49:37 -0700 (PDT), DanielC <dnlchen@gmail.com> wrote:

>On Jun 11, 2:09 am, praveenzx <pravee...@gmail.com> wrote:
>> Hey DanielC
>>
>> Try this one..
>>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> my $PSNOW="test.txt";
>> open(FH, $PSNOW) or die "Can't open $PSNOW: $!";
>> my @lines = <FH>;
>> my $task="AA::Task::AAAA";
>>
>> my @arglist=qw(cId 2 sId 3);
>> my $pattern = $task . '[^0-9]*' . join('[^0-9]*',@arglist);
>>
>> my $count = scalar grep { /$pattern/ } @lines;
>> print "$count\n";
>
>my $pattern = $task . '[^0-9]*' . join('[^0-9]*',@arglist) . '(\)|$)';
>
>yes, [^0-9]* is good for this case, plus '(\)|$)' make it perfect.
>
>Is there any better match than [^0-9]*? [^0-9]* also matches 'cId" and
>'sId'.

Sure, serialized.

Either adjacent:

  my $pnoc      = '(?:[^,\PP]|\s)';
  my $field_sep = "(?:$pnoc*,$pnoc*|$pnoc+)";
  my $pattern   = $task . $field_sep . join( $field_sep, @arglist ) . $field_sep;
  print "\n", '-'x20, "\n$pattern\n", '-'x20;
  my @found = grep { /$pattern/ } @lines;
  print "\nfound ". @found. " lines:\n";
  print "$_" for (@found);

Or not:

  my $field_sep = '(?:\b.*\b)';
  my $pattern   = $task . $field_sep . join( $field_sep, @arglist ) . $field_sep;
  print "\n", '-'x20, "\n$pattern\n", '-'x20;
  my @found = grep { /$pattern/ } @lines;
  print "\nfound ". @found. " lines:\n";
  print "$_" for (@found);

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

The biggest mistake yahoo's make is they think they can throw a
whole bunch of junk at regex and expect a fantasy to come true with .*

-sln


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

Date: Mon, 13 Jun 2011 00:34:43 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Regex Matching
Message-Id: <87zklmipyk.fsf@sapphire.mobileactivedefense.com>

DanielC <dnlchen@gmail.com> writes:
> On Jun 10, 3:58 pm, Rainer Weikusat <rweiku...@mssgmbh.com> wrote:
>> DanielC <dnlc...@gmail.com> writes:
>> > The output is expected to be "4" which means 4 lines match. However it
>> > gets "5".  How can I make this script work?
>>
>> It works. You regexp is
>>
>> AA::Task::AAA.*cId.*2.*sId.*3
>>
>> and it matches these lines:
>>
>> > AA::Task::AAAA (cId,24,sId,13)
>> > AA::Task::AAAA (cId,2,sId,3)
>> > AA::Task::AAAA (cId,2,sId,3)
>> > AA::Task::AAAA --cId 2 --sId 3
>> > AA::Task::AAAA --cId 2 --sId 3
>>
>> A regexp matching only the last four lines would be (untested)
>>
>> AA::Task::AAA.*cId.2.*sId.3

[...]

> This doesn't match very well.

It matches four lines of the data you provided ...

> What if there is a line "AA::Task::AAAA
> (cId,24,sId,33)" ?

 ... and another (untested) way to achieve the same would be

my $trolling;

/?{ ++$trolling == 4 && die("Troll dich!")}/ || print;


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

Date: Mon, 13 Jun 2011 13:40:41 -0400
From: Adam Russell <ac.russell@live.com>
Subject: Re: require statement
Message-Id: <it5i2r$1vf$1@dont-email.me>

> Use a config file and/or command line switches.
Command line switches is my favorite. If I am writing a script using a 
module which is itself
also a work in progress I just specify its location on the command line 
with
perl -I /some/module/path my_script.pl
This fits my development style well but depending on the OP's use case 
it might be
easier to just put them in a standard directory, especially if they 
aren't being currently
developed.




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

Date: Sun, 12 Jun 2011 16:12:42 -0700
From: sln@netherlands.com
Subject: Re: The Forthcoder Diaries -- 2011 June 9
Message-Id: <ushav61qgnj4f5mcildrcqaj9ihp6hmap9@4ax.com>

On Fri, 10 Jun 2011 11:59:25 -0700 (PDT), Mentifex <mentifex@myuw.net> wrote:

>On Jun 10, 5:15 am, Brian Martin
><brianNOS...@futuresoftware.com.auNOSPAM> wrote:
>> Then again you could use a high level language like Perl, Python, APL ...
>>
>> On 10/06/2011 8:17 AM, Paul Rubin wrote:
>>
>> > Mentifex<menti...@myuw.net>  writes:
>> >> At one point, I had to create 8jun11T.F as a "Test" version of
>> >> MindForth, so that I could fix the JavaScript AI in comparison with
>> >> the Forth AI.
>>
>> > You could use both:
>>
>> >    http://forthfreak.net/jsforth80x25.html
>>
>Perl programmers have the opportunity to port
>
>http://www.scn.org/~mentifex/AiMind.html
>
>to run on Web servers as a resident AI Mind.
>
>Mentifex (Arthur)

Please post a sample of the Perl script your having
problems with, along with a problem statement.

-sln


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

Date: Mon, 13 Jun 2011 06:18:57 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Unicode labels with Chart::Composite
Message-Id: <eli$1106130213@qz.little-neck.ny.us>

In comp.lang.perl.misc, David Combs <dkcombs@panix.com> wrote:
> Sort both off and on topic -- Anywone here ever tried using
> the Bell Labs (20 yrs ago) super-powerful statistics and
> graphics package "The NEW S-Language",
> since then privitized, and thus a from-scratch-developed 
> open-source freebie version named "R"?

I have not, but I've heard about it.

> If people here do know about R, and think it valuable,
> at least for super-powerful graphics (charts, Chernov faces,
> box plots, you name it), and it isn't already in CPAN --
> well, should it be?

Chernov faces. That got my attention. So I checked, not CPAN,
just google, and I found this:

http://www.omegahat.org/RSPerl/RFromPerl.html

Which shows it to be a complicated beast. Perl calls R, but
R is also configured to call Perl back. This tight integration
probably makes data flow convient, but it seems much more
involved to install than a regular CPAN module.

I'll probably get around to trying it soonish. Complicated
installs usually don't scare me, but they are time consuming.

Elijah
------
speaking as someone who has compiled Firefox and Gimp from source


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

Date: Sun, 12 Jun 2011 16:28:55 -0700
From: sln@netherlands.com
Subject: Re: Warning in one statement, not in apparently identical one
Message-Id: <8liav6hrfppavstcm5ngcsa992ok6vn249@4ax.com>

On Wed, 08 Jun 2011 13:36:31 +0200, Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net> wrote:

>On 08.06.2011 13:26, Henry Law wrote:
>> I'm trying to write proper Perlish shorthand for some of the tests in a 
>> subroutine, which when the parameters are wrong have to return FALSE as 
>> well as setting $@.  Boiled down, it looks like this:
>> 
>> #!/usr/bin/perl
>> 
>> use strict; use warnings;
>> 
>> sub my_sub{
>>    my $file = shift;
>>    $@ = "No file supplied" and return 0 unless $file;
>>    $@ = "File '$file' not found or not a readable file" and return 0 
>> unless -r $file;
>> }
>> 
>> The compiler objects to the first one "Found = in conditional, should be 
>> == at error.pl line 7" but not to the second; but unless my eyes have 
>> gone funny they are syntactically identical.
>> 
>> It's only a warning but I have a policy of requiring clean compiles. 
>> What am I doing wrong?
>
>In line 7 you basically have:
>assignment and return
>
>So Perl warns that the assignment should probably be a comparison,
>because otherwise the "and" does not make sense here as the constant
>string you are assigning is always true.
>
>You can use the comma operator instead of "and".
>
>Another thing: you want your sub to return FALSE. But you are returning
>0 instead. This is a difference in list context: 1 element (the 0) is
>true. So if you want to return false, just write "return;".
>

Is line 7 an error, then stop?
I don't get it. Is line 7 different than line 8? Or, does the compiler feel
it only needs to warn once on sequential similar error lines of this janra?
Or posibly line 7 is indeed different in syntax.

-sln


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

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


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