[31300] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2545 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 11 06:09:42 2009

Date: Tue, 11 Aug 2009 03: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           Tue, 11 Aug 2009     Volume: 11 Number: 2545

Today's topics:
    Re: FAQ 8.18 How can I do an atexit() or setjmp()/longj <nospam-abuse@ilyaz.org>
    Re: FAQ 8.18 How can I do an atexit() or setjmp()/longj <hjp-usenet2@hjp.at>
        footer in format <abu.4000@gmail.com>
        more than one statement in a post perlish condition <abu.4000@gmail.com>
    Re: more than one statement in a post perlish condition <peter@makholm.net>
    Re: more than one statement in a post perlish condition <ben@morrow.me.uk>
    Re: Perl process as a unix background process gbostock@excite.com
    Re: Perl process as a unix background process <m@rtij.nl.invlalid>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@seesig.invalid
    Re: regular expressions <tadmc@seesig.invalid>
    Re: regular expressions sln@netherlands.com
    Re: regular expressions <mud_saisem@hotmail.com>
    Re: regular expressions <nat.k@gm.ml>
        rows affected not working.. <fgnowfg@gmail.com>
        Social problems of Python doc [was Re: Python docs disa <xahlee@gmail.com>
        Tkx checkbutton font <kenslaterpa@hotmail.com>
    Re: using file globs and regex <pgodfrin@gmail.com>
    Re: using file globs and regex <smallpond@juno.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 10 Aug 2009 16:48:39 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: FAQ 8.18 How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
Message-Id: <slrnh80jbs.4p6.nospam-abuse@chorin.math.berkeley.edu>

On 2009-08-10, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> Yes. END{} and atexit() are closely related, but have little (if
> anything) to do with exception handling.

As I already said, in my book they do.  Apparently, your notion of
exception handling is much more narrow...  Or maybe you think "clean
up and report to operator" is not a kind of handling too?

> setjmp/longjmp can be used for exception handling and would usually be
> replaced with die/eval{} in Perl (although next/last LABEL may be an
> alternative in some situations).

Here you might contradict yourself.  AFAIK, any kind of exceptions
which may be caught by die/eval{} is also caught by END{}.  (E.g.,
neither will handle signals without help of %SIG.)

Hope this helps,
Ilya


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

Date: Mon, 10 Aug 2009 12:56:43 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 8.18 How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
Message-Id: <slrnh7vv7b.7ii.hjp-usenet2@hrunkner.hjp.at>

On 2009-08-08 02:16, Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> brian d foy wrote:
>> In article <lniqh4o31c.fsf@nuthaus.mib.org>, Keith Thompson
>> <kst-u@mib.org> wrote:
>> 
>>> PerlFAQ Server <brian@stonehenge.com> writes:
>>>> 8.18: How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
>>>>
>>>>     Release 5 of Perl added the END block, which can be used to
>>>>     simulate atexit(). Each package's END block is called when the
>>>>     program or thread ends (see perlmod manpage for more details).
>> 
>> 
>>> Since Perl 5 is so old, I suggest it's not worth mentioning when this
>>> was added.  The END block is just a feature of Perl.
>> 
>> I'm not even sure what the point of the question is. END blocks aren't
>> good for exception handling because you're not really handling
>> anything; you're just getting ready to stop.
>
> But the same can be said about atexit in C, can't it?

Yes. END{} and atexit() are closely related, but have little (if
anything) to do with exception handling.

setjmp/longjmp can be used for exception handling and would usually be
replaced with die/eval{} in Perl (although next/last LABEL may be an
alternative in some situations).


>> This might be another candidate for the bit bucket.
>
> I think it still makes sense, just as two different questions.
>
> atexit and setjmp/longjmp seem to be two rather different topics, I 
> don't know why they are combined.

Agreed.

	hp


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

Date: Sun, 9 Aug 2009 21:44:57 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: footer in format
Message-Id: <156bbdf6-0a11-4dc4-aacd-220f5cd5e90f@l5g2000pra.googlegroups.com>

Dear all
how to print the footer using format in perl

use strict;
use warnings;
my ( $name, $x, $uid, $gid, $power, $boot, $path );
format STDOUT=
        @>>>> @> @<<<< @##### @>>>> @<<<< @>>>>>>>>>>>>>>>>>>
        $name, $x, $uid, $gid, $power, $boot, $path
 .


format STDOUT_TOP =
        -----------------------------------------
        Name passwd     UID      GID    POWER   BOOT    PATH
page :@<
 $%
        -----------------------------------------
 .


format STDOUT_BOTTOM =
                  End of Page @<
                                          $%
 .


#$~ = "report";
#$~=STDOUT_BOTTOM;
#select(STDOUT);
open FH , "/etc/passwd" ;
while (( $name, $x, $uid, $gid, $power, $boot, $path )=split ":" ,
<FH>){

write ;
}
> This code is not printing the STDOUT_BOTTOM
> Please I want very basic definition , since I am a beginner
> I have tried a lot please help me out


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

Date: Mon, 10 Aug 2009 22:22:39 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: more than one statement in a post perlish condition
Message-Id: <46cebd5b-450e-4d19-913a-55ca655554a4@y28g2000prd.googlegroups.com>

Dear community ,
I wanted to know that how do I give more than one statement in a post
perlish condition ,

for ex:
print "YES" if ( $yes eq "yes");


I want to change the value of $yes if it is true that means it should
execute after
print statement.

Thanks in Advance


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

Date: Tue, 11 Aug 2009 08:08:04 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <8763cuq3wb.fsf@vps1.hacking.dk>

Alexander Jack <abu.4000@gmail.com> writes:

> Dear community ,
> I wanted to know that how do I give more than one statement in a post
> perlish condition ,
>
> for ex:
> print "YES" if ( $yes eq "yes");

For more than one simple statement I would almost always use a real if
block

  if ($yes eq "yes") {
      print "YES";
      $yes = "no;
  }

If you for some reason want to hide the condition as a statement
modifier you could use a do block:

  do {
      print "YES";
      $yes = "no";
  } if $yes eq "yes";

It is possible to do something like

  print("YES"), $yes = "no"   if $yes eq "yes";
  (print "YES"), $yes = "no"  if $yes eq "yes";
  print "YES" and $yes = "no" if $yse eq "yes";

but I consider all of them less readable than the block forms and at
least the last example isn't obvious for people not quite used to perl
precedence rules.

//Makholm.


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

Date: Tue, 11 Aug 2009 09:32:41 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <9um7l6-8e72.ln1@osiris.mauzo.dyndns.org>


Quoth Peter Makholm <peter@makholm.net>:
> 
> It is possible to do something like
> 
>   print("YES"), $yes = "no"   if $yes eq "yes";
>   (print "YES"), $yes = "no"  if $yes eq "yes";
>   print "YES" and $yes = "no" if $yse eq "yes";
> 
> but I consider all of them less readable than the block forms and at
> least the last example isn't obvious for people not quite used to perl
> precedence rules.

The last example is also Wrong, in that print can fail. It's not common,
and it's rarely worth checking for (checking for error on close is
usually better; if you're worried about detecting failure of individual
writes you probably want to be using syswrite anyway, so you know what
you're getting), but it can happen.

Ben



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

Date: Mon, 10 Aug 2009 08:28:22 -0700 (PDT)
From: gbostock@excite.com
Subject: Re: Perl process as a unix background process
Message-Id: <afd03e12-15cc-4b82-a319-6f0c36efb812@o35g2000vbi.googlegroups.com>


Thanks, your post led me to the solution to the problem and I didn't
have to guess at lines of code.

Sorry about the hide text business, it's an artifact of using Google.
I trimmed the whole thing this time


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

Date: Mon, 10 Aug 2009 21:42:35 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Perl process as a unix background process
Message-Id: <bq96l6-7pb.ln1@news.rtij.nl>

On Mon, 10 Aug 2009 08:28:22 -0700, gbostock wrote:

> Thanks, your post led me to the solution to the problem and I didn't
> have to guess at lines of code.

Care to share what was wrong? I'm interested now.

M4


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

Date: Tue, 11 Aug 2009 02:18:06 -0500
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <_tKdnSIKg9SzhhzXnZ2dnUVZ_hmdnZ2d@giganews.com>

Outline
   Before posting to comp.lang.perl.misc
      Must
       - Check the Perl Frequently Asked Questions (FAQ)
       - Check the other standard Perl docs (*.pod)
      Really Really Should
       - Lurk for a while before posting
       - Search a Usenet archive
      If You Like
       - Check Other Resources
   Posting to comp.lang.perl.misc
      Is there a better place to ask your question?
       - Question should be about Perl, not about the application area
      How to participate (post) in the clpmisc community
       - Carefully choose the contents of your Subject header
       - Use an effective followup style
       - Speak Perl rather than English, when possible
       - Ask perl to help you
       - Do not re-type Perl code
       - Provide enough information
       - Do not provide too much information
       - Do not post binaries, HTML, or MIME
      Social faux pas to avoid
       - Asking a Frequently Asked Question
       - Asking a question easily answered by a cursory doc search
       - Asking for emailed answers
       - Beware of saying "doesn't work"
       - Sending a "stealth" Cc copy
      Be extra cautious when you get upset
       - Count to ten before composing a followup when you are upset
       - Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------

Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
    This newsgroup, commonly called clpmisc, is a technical newsgroup
    intended to be used for discussion of Perl related issues (except job
    postings), whether it be comments or questions.

    As you would expect, clpmisc discussions are usually very technical in
    nature and there are conventions for conduct in technical newsgroups
    going somewhat beyond those in non-technical newsgroups.

    The article at:

        http://www.catb.org/~esr/faqs/smart-questions.html

    describes how to get answers from technical people in general.

    This article describes things that you should, and should not, do to
    increase your chances of getting an answer to your Perl question. It is
    available in POD, HTML and plain text formats at:

     http://www.rehabitation.com/clpmisc.shtml

    For more information about netiquette in general, see the "Netiquette
    Guidelines" at:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

    A note to newsgroup "regulars":

       Do not use these guidelines as a "license to flame" or other
       meanness. It is possible that a poster is unaware of things
       discussed here.  Give them the benefit of the doubt, and just
       help them learn how to post, rather than assume that they do 
       know and are being the "bad kind" of Lazy.

    A note about technical terms used here:

       In this document, we use words like "must" and "should" as
       they're used in technical conversation (such as you will
       encounter in this newsgroup). When we say that you *must* do
       something, we mean that if you don't do that something, then
       it's unlikely that you will benefit much from this group.
       We're not bossing you around; we're making the point without
       lots of words.

    Do *NOT* send email to the maintainer of these guidelines. It will be
    discarded unread. The guidelines belong to the newsgroup so all
    discussion should appear in the newsgroup. I am just the secretary that
    writes down the consensus of the group.

Before posting to comp.lang.perl.misc
  Must
    This section describes things that you *must* do before posting to
    clpmisc, in order to maximize your chances of getting meaningful replies
    to your inquiry and to avoid getting flamed for being lazy and trying to
    have others do your work.

    The perl distribution includes documentation that is copied to your hard
    drive when you install perl. Also installed is a program for looking
    things up in that (and other) documentation named 'perldoc'.

    You should either find out where the docs got installed on your system,
    or use perldoc to find them for you. Type "perldoc perldoc" to learn how
    to use perldoc itself. Type "perldoc perl" to start reading Perl's
    standard documentation.

    Check the Perl Frequently Asked Questions (FAQ)
        Checking the FAQ before posting is required in Big 8 newsgroups in
        general, there is nothing clpmisc-specific about this requirement.
        You are expected to do this in nearly all newsgroups.

        You can use the "-q" switch with perldoc to do a word search of the
        questions in the Perl FAQs.

    Check the other standard Perl docs (*.pod)
        The perl distribution comes with much more documentation than is
        available for most other newsgroups, so in clpmisc you should also
        see if you can find an answer in the other (non-FAQ) standard docs
        before posting.

    It is *not* required, or even expected, that you actually *read* all of
    Perl's standard docs, only that you spend a few minutes searching them
    before posting.

    Try doing a word-search in the standard docs for some words/phrases
    taken from your problem statement or from your very carefully worded
    "Subject:" header.

  Really Really Should
    This section describes things that you *really should* do before posting
    to clpmisc.

    Lurk for a while before posting
        This is very important and expected in all newsgroups. Lurking means
        to monitor a newsgroup for a period to become familiar with local
        customs. Each newsgroup has specific customs and rituals. Knowing
        these before you participate will help avoid embarrassing social
        situations. Consider yourself to be a foreigner at first!

    Search a Usenet archive
        There are tens of thousands of Perl programmers. It is very likely
        that your question has already been asked (and answered). See if you
        can find where it has already been answered.

        One such searchable archive is:

         http://groups.google.com/advanced_search

  If You Like
    This section describes things that you *can* do before posting to
    clpmisc.

    Check Other Resources
        You may want to check in books or on web sites to see if you can
        find the answer to your question.

        But you need to consider the source of such information: there are a
        lot of very poor Perl books and web sites, and several good ones
        too, of course.

Posting to comp.lang.perl.misc
    There can be 200 messages in clpmisc in a single day. Nobody is going to
    read every article. They must decide somehow which articles they are
    going to read, and which they will skip.

    Your post is in competition with 199 other posts. You need to "win"
    before a person who can help you will even read your question.

    These sections describe how you can help keep your article from being
    one of the "skipped" ones.

  Is there a better place to ask your question?
    Question should be about Perl, not about the application area
        It can be difficult to separate out where your problem really is,
        but you should make a conscious effort to post to the most
        applicable newsgroup. That is, after all, where you are the most
        likely to find the people who know how to answer your question.

        Being able to "partition" a problem is an essential skill for
        effectively troubleshooting programming problems. If you don't get
        that right, you end up looking for answers in the wrong places.

        It should be understood that you may not know that the root of your
        problem is not Perl-related (the two most frequent ones are CGI and
        Operating System related), so off-topic postings will happen from
        time to time. Be gracious when someone helps you find a better place
        to ask your question by pointing you to a more applicable newsgroup.

  How to participate (post) in the clpmisc community
    Carefully choose the contents of your Subject header
        You have 40 precious characters of Subject to win out and be one of
        the posts that gets read. Don't waste them. Take care while
        composing them, they are the key that opens the door to getting an
        answer.

        Spend them indicating what aspect of Perl others will find if they
        should decide to read your article.

        Do not spend them indicating "experience level" (guru, newbie...).

        Do not spend them pleading (please read, urgent, help!...).

        Do not spend them on non-Subjects (Perl question, one-word
        Subject...)

        For more information on choosing a Subject see "Choosing Good
        Subject Lines":

         http://www.cpan.org/authors/id/D/DM/DMR/subjects.post

        Part of the beauty of newsgroup dynamics, is that you can contribute
        to the community with your very first post! If your choice of
        Subject leads a fellow Perler to find the thread you are starting,
        then even asking a question helps us all.

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* each section of quoted text to
        which they relate. Unappreciated followup styles are referred to as
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://web.presby.edu/~nnqadmin/nnq/nquote.html

    Speak Perl rather than English, when possible
        Perl is much more precise than natural language. Saying it in Perl
        instead will avoid misunderstanding your question or problem.

        Do not say: I have variable with "foo\tbar" in it.

        Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
        or I have $var = <DATA> (and show the data line).

    Ask perl to help you
        You can ask perl itself to help you find common programming mistakes
        by doing two things: enable warnings (perldoc warnings) and enable
        "strict"ures (perldoc strict).

        You should not bother the hundreds/thousands of readers of the
        newsgroup without first seeing if a machine can help you find your
        problem. It is demeaning to be asked to do the work of a machine. It
        will annoy the readers of your article.

        You can look up any of the messages that perl might issue to find
        out what the message means and how to resolve the potential mistake
        (perldoc perldiag). If you would like perl to look them up for you,
        you can put "use diagnostics;" near the top of your program.

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.

    Provide enough information
        If you do the things in this item, you will have an Extremely Good
        chance of getting people to try and help you with your problem!
        These features are a really big bonus toward your question winning
        out over all of the other posts that you are competing with.

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.

        Show the output (including the verbatim text of any messages) of
        your program.

        Describe how you want the output to be different from what you are
        getting.

        If you have no idea at all of how to code up your situation, be sure
        to at least describe the 2 things that you *do* know: input and
        desired output.

    Do not provide too much information
        Do not just post your entire program for debugging. Most especially
        do not post someone *else's* entire program.

    Do not post binaries, HTML, or MIME
        clpmisc is a text only newsgroup. If you have images or binaries
        that explain your question, put them in a publically accessible
        place (like a Web server) and provide a pointer to that location. If
        you include code, cut and paste it directly in the message body.
        Don't attach anything to the message. Don't post vcards or HTML.
        Many people (and even some Usenet servers) will automatically filter
        out such messages. Many people will not be able to easily read your
        post. Plain text is something everyone can read.

  Social faux pas to avoid
    The first two below are symptoms of lots of FAQ asking here in clpmisc.
    It happens so often that folks will assume that it is happening yet
    again. If you have looked but not found, or found but didn't understand
    the docs, say so in your article.

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

    Asking a question easily answered by a cursory doc search
        If folks think you have not even tried the obvious step of reading
        the docs applicable to your problem, they are likely to become
        annoyed.

        If you are flamed for not checking when you *did* check, then just
        shrug it off (and take the answer that you got).

    Asking for emailed answers
        Emailed answers benefit one person. Posted answers benefit the
        entire community. If folks can take the time to answer your
        question, then you can take the time to go get the answer in the
        same place where you asked the question.

        It is OK to ask for a *copy* of the answer to be emailed, but many
        will ignore such requests anyway. If you munge your address, you
        should never expect (or ask) to get email in response to a Usenet
        post.

        Ask the question here, get the answer here (maybe).

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

    Sending a "stealth" Cc copy
        A "stealth Cc" is when you both email and post a reply without
        indicating *in the body* that you are doing so.

  Be extra cautious when you get upset
    Count to ten before composing a followup when you are upset
        This is recommended in all Usenet newsgroups. Here in clpmisc, most
        flaming sub-threads are not about any feature of Perl at all! They
        are most often for what was seen as a breach of netiquette. If you
        have lurked for a bit, then you will know what is expected and won't
        make such posts in the first place.

        But if you get upset, wait a while before writing your followup. I
        recommend waiting at least 30 minutes.

    Count to ten after composing and before posting when you are upset
        After you have written your followup, wait *another* 30 minutes
        before committing yourself by posting it. You cannot take it back
        once it has been said.

AUTHOR
    Tad McClellan and many others on the comp.lang.perl.misc newsgroup.

-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 09 Aug 2009 21:51:04 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: regular expressions
Message-Id: <slrnh7v29r.6fv.tadmc@tadmc30.sbcglobal.net>

mud_saisem <mud_saisem@hotmail.com> wrote:

> Could anybody please let me know how I would be able to extract the
> words that have a = in the middle and print the whole word out.


> $string = "This is a example item, order=TEST:ITEM:123 on shelf
> shelf=1:4:23:f";


    print "$_\n" for grep /=/, split /\s+/, $string;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 10 Aug 2009 12:19:23 -0700
From: sln@netherlands.com
Subject: Re: regular expressions
Message-Id: <q6r0859qa0td961ssci9hnfcmq54ikqhoe@4ax.com>

On Sun, 9 Aug 2009 15:25:24 -0700 (PDT), mud_saisem <mud_saisem@hotmail.com> wrote:

>Hi There,
>
>Could anybody please let me know how I would be able to extract the
>words that have a = in the middle and print the whole word out. Also I
>will never know how many : and in the word either.
>
>eg: "This is a example item, order=TEST:ITEM:123 on shelf
>shelf=1:4:23:f"
>
>output: order=TEST:ITEM:123
>           shelf=1:4:23:f
>
>This is what I have done so far but only prints out the word until the
>first :
>
>eg: order=TEST
>
>
>
>#!/usr/bin/perl
>
>system(clear);
>
>$string = "This is a example item, order=TEST:ITEM:123 on shelf
>shelf=1:4:23:f";
>$str = $string;
>
>print "String: $string\n\n";
>sub extract
>{
>        $x = shift;
>        print "Checking: $x\n";
>        return $x;
>}
>
>$string =~ s/(\w+=\w+)/extract $1/ge;
>
>print "\n";

Just a comment on your example string.
You have a rambling/random, englishly, seemingly un-delimited
string. Then all of a sudden, there is this perfect, parsable
slug of data that doesen't fit:

   order=TEST:ITEM:123

Instantly the data slug is on a \s boundry and triggered by '='.
This is not an example for anything. It could just as well have been:

   order this = 'TEST:ITEM' : 123

In reality, constructing regular expressions from unknown/unreliable,
computer generated data falling in the range of repeatablility, including
variances, are an entirely different thing.

Learning word boundries and classes is one thing. Its obvious you know what
they are otherwise you would not have constructed such a blatant example that
applies to absolutely nothing else.

Constructing a quiz for the pupils?
Seriously, you should get more realistic examples. Plucking
 ' order=TEST:ITEM:123 ' from random wordy text is as basic as it comes.
Given your doing eval with func call in global context an all, have to wonder
about your motivations.

My opinion on this group (or any group) is that using real world examples
reap the most reward.

-sln


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

Date: Mon, 10 Aug 2009 16:43:21 -0700 (PDT)
From: mud_saisem <mud_saisem@hotmail.com>
Subject: Re: regular expressions
Message-Id: <02cbdd41-54f5-4900-a6c8-245be51250e5@o9g2000prg.googlegroups.com>

On Aug 11, 5:19=A0am, s...@netherlands.com wrote:
> On Sun, 9 Aug 2009 15:25:24 -0700 (PDT), mud_saisem <mud_sai...@hotmail.c=
om> wrote:
> >Hi There,
>
> >Could anybody please let me know how I would be able to extract the
> >words that have a =3D in the middle and print the whole word out. Also I
> >will never know how many : and in the word either.
>
> >eg: "This is a example item, order=3DTEST:ITEM:123 on shelf
> >shelf=3D1:4:23:f"
>
> >output: order=3DTEST:ITEM:123
> > =A0 =A0 =A0 =A0 =A0 shelf=3D1:4:23:f
>
> >This is what I have done so far but only prints out the word until the
> >first :
>
> >eg: order=3DTEST
>
> >#!/usr/bin/perl
>
> >system(clear);
>
> >$string =3D "This is a example item, order=3DTEST:ITEM:123 on shelf
> >shelf=3D1:4:23:f";
> >$str =3D $string;
>
> >print "String: $string\n\n";
> >sub extract
> >{
> > =A0 =A0 =A0 =A0$x =3D shift;
> > =A0 =A0 =A0 =A0print "Checking: $x\n";
> > =A0 =A0 =A0 =A0return $x;
> >}
>
> >$string =3D~ s/(\w+=3D\w+)/extract $1/ge;
>
> >print "\n";
>
> Just a comment on your example string.
> You have a rambling/random, englishly, seemingly un-delimited
> string. Then all of a sudden, there is this perfect, parsable
> slug of data that doesen't fit:
>
> =A0 =A0order=3DTEST:ITEM:123
>
> Instantly the data slug is on a \s boundry and triggered by '=3D'.
> This is not an example for anything. It could just as well have been:
>
> =A0 =A0order this =3D 'TEST:ITEM' : 123
>
> In reality, constructing regular expressions from unknown/unreliable,
> computer generated data falling in the range of repeatablility, including
> variances, are an entirely different thing.
>
> Learning word boundries and classes is one thing. Its obvious you know wh=
at
> they are otherwise you would not have constructed such a blatant example =
that
> applies to absolutely nothing else.
>
> Constructing a quiz for the pupils?
> Seriously, you should get more realistic examples. Plucking
> =A0' order=3DTEST:ITEM:123 ' from random wordy text is as basic as it com=
es.
> Given your doing eval with func call in global context an all, have to wo=
nder
> about your motivations.
>
> My opinion on this group (or any group) is that using real world examples
> reap the most reward.
>
> -sln

Sln,

Thanks for your comments.

The examples that I have given are based on problems that I can not
figure out and need help with.

If I put in real world example as you call it, It would still make no
sense to you or any other person reading this discussion. I ask for
help on what I need to resolve my issue and never intended this to be
a learning curve for pupils.

Personally I don't see what the issue is as others have managed to
give very good and efficient solutions to the problem that I face.

But I your point is taken !

I am still very new at perl, and in the future I will put in better
examples WHERE POSSIBLE.


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

Date: Mon, 10 Aug 2009 17:33:57 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: regular expressions
Message-Id: <W%2gm.61120$0z7.6711@newsfe07.iad>

mud_saisem wrote:

> 
> Personally I don't see what the issue is as others have managed to
> give very good and efficient solutions to the problem that I face.

Ignore him, this is common.  He rarely provides real help and often
gives broken code when he does try (which I can sort of appreciate),
but his motivation here is usually to either try and show off or berate
someone else.  A lot of people have filtered his posts.  Don't let it
get to you.


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

Date: Mon, 10 Aug 2009 19:22:32 -0700 (PDT)
From: Faith Greenwood <fgnowfg@gmail.com>
Subject: rows affected not working..
Message-Id: <d8049316-dae2-4bc5-b99c-40267ab7cf1c@o6g2000yqj.googlegroups.com>

Hi,

I am making some changes to my mysql table via DBI (I am inserting the
ages of the people I already have in the table). I have the following:

my $sql="UPDATE table SET age=? WHERE name=?";
my $sth=$dbh->prepare($sql);
$sth->execute($age,$name) or warn "$DBI::errstr\n" and next;
my $rc = $sth->rows;

I have 100 records total. Of course, when I run this script the first
time I update the age column of every single person in the table and
$rc=1 for each of the 100 rows. However, running the script the 2nd
time (without changing any of the ages), I still get $rc=1 for each of
the 100 rows (it should be zero, since the row actually wasn't
updated).

To check, I updated a record via phpmyadmin and got 0 rows affected
(like it should). Why is Perl giving me the wrong response? More
importantly, how do I correct it?

thx!


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

Date: Sun, 9 Aug 2009 20:04:43 -0700 (PDT)
From: Xah Lee <xahlee@gmail.com>
Subject: Social problems of Python doc [was Re: Python docs disappointing]
Message-Id: <6fa250dc-b7cf-43a6-ab1d-598c2a8e5cc8@v23g2000pro.googlegroups.com>

The prob with python docs is with the python priests.

there are frequent posts about python doc's poor quality, and some
efforts to improve the doc (such as wiki or seggestions), about few
times a year (in so much as i've seen), the typical response is
pissing fight, with python priests to tell them not to start another
wiki, or =E2=80=9Cyou should apply in our church first and formulate a PEP
proposal first or kindly donate or otherwise fuckoff=E2=80=9D, and so on.

i've wrote several articles about this issue, total time spend on this
is probably more than 2 months full-time work. See:

=E2=80=A2 Python Documentation Problems
  http://xahlee.org/perl-python/python_doc_index.html

just about each article above generates a thread of flames.

I also have re-wrote the entire python regex doc in 2005:

=E2=80=A2 Pyhton Regex Documentation: String Pattern Matching
  http://xahlee.org/perl-python/python_re-write/lib/module-re.html

there are some positive reviews, but most are drawn out by nay-sayers.

I often receive thank you emails for 2 particular articles, which are
most frequently google searched as indicated by my weblog:

=E2=80=A2 Python Doc Problem Example: gzip
  http://xahlee.org/perl-python/python_doc_gzip.html

=E2=80=A2 Python Doc Problem Example: sort()
  http://xahlee.org/perl-python/python_doc_sort.html

=E2=80=A2 Sorting in Python and Perl
  http://xahlee.org/perl-python/sort_list.html

See also:

=E2=80=A2 Language, Purity, Cult, and Deception
  http://xahlee.org/UnixResource_dir/writ/lang_purity_cult_deception.html

  Xah
=E2=88=91 http://xahlee.org/

=E2=98=84

On Jul 31, 1:10 pm, kj <no.em...@please.post> wrote:
> I'm pretty new to Python, and I like a lot overall, but I find the
> documentation for Python rather poor, overall.
>
> I'm sure that Python experts don't have this problem: they have
> internalized some good ways to access the documentation, are
> productive with it, and therefore have lost the ability to see why
> the Python documentations is deficient for beginners.  This explains
> why a suboptimal situation can persist like this: those who are
> most able fix it are also the least able to perceive it.
>
> I've heard similar complaints from other experienced programmers
> who are trying out Python for the first time: poor documentation.
>
> Here is an *entirely typical* example: on some Unix, try
>
> % pydoc urllib
>
> The displayed documentation mention the optional parameter "data"
> in practically every function listed (a few dozen of them).  This
> parameter is not documented *anywhere* on that page.  All that we
> are told is that its default value is always None.
>
> I'm sure that I can find a full description of this parameter if
> I fire up Google, and search online.  In fact, more likely than
> not, I'll find far more documentation than I want.  But my point
> is that a programmer should not need to do this.  The full
> documentation should be readily accessible directly through a few
> keystrokes.
>
> I would love to know how experienced Python programmers quickly
> zero in on the Python documentation they need.
>
> TIA!
>
> kynn



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

Date: Mon, 10 Aug 2009 11:36:43 -0700 (PDT)
From: kens <kenslaterpa@hotmail.com>
Subject: Tkx checkbutton font
Message-Id: <5907ed37-99f4-40db-953d-8887adfbdb90@p15g2000vbl.googlegroups.com>

Hi all,

I have recently started to look at the Tkx module for developing GUI-
based applications. In the past I have used Tk.

I am having trouble setting the font on a checkbutton's text. The code
below does not compile, it gives the error:

unknown option "-font" at test.pl line 12.

---CODE---
use strict;
use warnings;
use Tkx;

my $font        = 'Courier 10 normal';

my (
    $reset,
);

my $mw         = Tkx::widget->new('.');
(my $resetButton = $mw->new_ttk__checkbutton
                    (-text     => 'Reset',
                     -variable => \$reset,
# The -font option causes error
                     -font     => $font,
                     -onvalue   => 1,
                     -offvalue  => 0,
                     ))->g_pack(-side=>'top', -anchor=>'w');
Tkx::MainLoop();
--- End CODE ---

The Tk reference (http://www.tcl.tk/man/tcl8.5/TkCmd/
checkbutton.htm#M16) indicates the '-font' is a standard option for a
checkbutton.

Is this option just not implemented in Perl::Tkx?  Or is there a
different option?

Thanks,
Ken Slater


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

Date: Mon, 10 Aug 2009 11:20:36 -0700 (PDT)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: using file globs and regex
Message-Id: <c82dc5bb-2af7-4836-9d5a-f71cbe80ba31@q35g2000vbi.googlegroups.com>

On Aug 7, 3:44=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> [please don't top-post]
>
> Quoth pgodfrin <pgodf...@gmail.com>:
>
> > OK - I figured it out - thanks.
>
> > This works fine: my($fn2) =3D grep ( $_ =3D~ '6' , glob 'f*');
>
> > What I'm confused about is the parens around the $fn2 ? Why are those
> > needed? Something tells me that has something to do with making the
> > scalar $fn2 into a list 'cause that's what grep returns, but i can't
> > remember what that's called to look it up.
>
> =A0 =A0 my $x =3D ...
>
> evaluates the RHS in scalar context, but
>
> =A0 =A0 my ($x) =3D ...
>
> evaluates it in list context. The same applies without the 'my', or with
> 'local' instead. This is one of the few cases where explicit parens make
> a difference in deciding whether something is a list or not.
>
> Ben

Nice to hear from you Ben (hope things are well).
Thanks Ben and Tad for clearing up the 'context'.
Of course, you're right Tad - the code assumes the first one it finds
is the right one. In this case that should be ok - but knowing more
about that behavior is a good thing (and might keep me from posting
some other day).

(sorry about the top post)
pg



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

Date: Mon, 10 Aug 2009 14:39:35 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: using file globs and regex
Message-Id: <h5pq10$mbn$1@news.eternal-september.org>

Ben Morrow wrote:
> [please don't top-post]
> 
> Quoth Steve C <smallpond@juno.com>:
>> - SC.
>>
>> then it asks grep for a scalar.
>> but when you call it without the parens
>> it asks grep for a list
> 
> Please don't talk nonsense.
> 
> Ben
> 

Too subtle, I guess.
SC


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

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


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