[21696] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3900 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 2 09:05:43 2002

Date: Wed, 2 Oct 2002 06:05:12 -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           Wed, 2 Oct 2002     Volume: 10 Number: 3900

Today's topics:
    Re: chdir then changing back (Helgi Briem)
    Re: Downloading from a www server: Problem develop@gistenson.com
    Re: How can I count files in a directory? (Helgi Briem)
    Re: How can I count files in a directory? (Helgi Briem)
    Re: How would you... THANKS ALL! <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How would you... THANKS ALL! <s.DONTwarhurstSPAM@rl.ac.MEuk>
    Re: ignore case in Greek (Tad McClellan)
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: Question about srand (Helgi Briem)
    Re: Search Patterns news@roaima.freeserve.co.uk
    Re: Send email from a Database Management Script news@roaima.freeserve.co.uk
    Re: Set many slots in a hash to the same defined value. (tî'pô)
    Re: Set many slots in a hash to the same defined value. <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Sticky forms without CGI.pm? <flavell@mail.cern.ch>
    Re: Sticky forms without CGI.pm? <pete@NOSPAMpopcornwebdesign.co.uk>
    Re: Sticky forms without CGI.pm? (Helgi Briem)
    Re: Top posting (was Re: How can I count files in a dir (Helgi Briem)
        Two email things in Perl (Adam Knowles)
    Re: Two email things in Perl <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Two email things in Perl <ubl@schaffhausen.de>
    Re: Two email things in Perl news@roaima.freeserve.co.uk
    Re: Two email things in Perl (Tad McClellan)
    Re: Use Java! Was: becoming a better programmer (Software Scavenger)
    Re: why does where matter? (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 02 Oct 2002 12:51:37 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: chdir then changing back
Message-Id: <3d9aeb3e.2003028552@news.cis.dfn.de>

On Wed, 02 Oct 2002 03:19:37 GMT, tadmc@augustmail.com (Tad
McClellan) wrote:

>[1] But you wouldn't put it immediately after the chdir()
>    call, because you need to check its return value :-)
>
>   chdir "../.." or die "could not back up two levels";

I would make that:
chdir "../.." or die "could not back up two levels:$!";
because I think the return value is contained in $!.

On the other hand, and this is a personal idiosyncracy
of mine, I never chdir within a Perl program unless
an external program I am using requires that it be
started in some particular location.

I always sit where I am and feed functions the full
path to whatever file/dir I want to use.

But, as I say, that's a personal quirk.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 2 Oct 2002 11:09:57 +0000 (UTC)
From: develop@gistenson.com
Subject: Re: Downloading from a www server: Problem
Message-Id: <anek65$g4v$1@flood.xnet.com>


Gregory,

I don't see how a form and submit can help. Please explain. I've been 
developing web sites since 1996, so I must be dense.

Thanks
Dan

Gregory Toomey <nobody@nowhere.com> wrote:


: develop@gistenson.com wrote in message ...
:>Tab and Alan,
:>
:>I'll try again.
:>
:>I'm developing a web site, not client-side software. The web site needs to
:>transfer files from it to the client.
:>
:>Alan, you're solution, using an anchor, is fine for downloading one file,
:>but I'm interested in a shopping cart application: A user, via his
:>browser, selects the items he wants to buy by clicking on a picture of
:>each item he intends to buy. This causes the item to be added to his
:>shopping cart. When the user has picked all of the items he wants to buy,
:>he clicks on a link, call it:
:>
:><a href="checkout.cgi">checkout</a>
:>
:>The script checkout.cgi is the script of interest here and needs to do the
:>following:
:>1. Initiate the credit card processing (No help needed here.)
:>2. Download to the user all of the purchased items. (The items are all
:>binary files.)
:>
:>The LWP documentation appears to say that LWP's purpose is at the machine
:>at the "receiveing" end of a file transfer. (ie. get, getprint and
:>getstore.) Am I wrong? I need something like putstore.
:>
:>I'm looking for guidance with the second of the above two "checkout"
:>steps.
:>
:>Thanks,
:>Dan
:>

: You need a standard cgi form and a submit button.

: gtoomey




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

Date: Wed, 02 Oct 2002 12:20:21 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How can I count files in a directory?
Message-Id: <3d9ae379.2001039532@news.cis.dfn.de>

On Tue, 1 Oct 2002 17:24:25 +0100, "Rubber Duck"
<rubberducky703@hotmail.com> wrote:

>Top Post????

Yes.  Top posting is to do as you do and stick your
answer at the top of an uncut chunk of previous
responses instead of cutting and pasting precisely
what you are responding to and putting your
answer after, so that the post may be read in
a proper chronological order as usenet etiquette
and common sense dictates.

Top-posting is incredibly annoying and rude and most 
usenet veterans simply killfile the top-poster and 
never ever respond to his posts again.

I give a couple of chances sometimes if the
top-poster is otherwise polite.

For a guide to posting to comp.lang.perl.misc read:
http://mail.augustmail.com/~tadmc/clpmisc.shtml

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

http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 02 Oct 2002 12:24:51 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How can I count files in a directory?
Message-Id: <3d9ae4aa.2001344170@news.cis.dfn.de>

On Tue, 1 Oct 2002 22:45:47 -0700, "Tan Nguyen"
<nospam@nospam.com> wrote:

>And if you hate using CPAN modules for a little/simple 
> task like myself ;-), you could roll one for yourself.
>
>[untested code, not much error checking]

Your code is a very very good argument for using the 
standard module.  What will your code do when
it encounters a recursive link?  Do you really want to
ignore all files that begin with a dot?

If you are incompetent, all the more reason to rely on
the professionally invented wheels that are readily
available instead of a square stone one you have
laboriously hacked out yourself.  

File::Find comes with every distribution of Perl.
It is very reliable and avoids the pitfalls that
beginners fall into.  
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 2 Oct 2002 10:10:04 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How would you... THANKS ALL!
Message-Id: <anegls$4iu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Bigus:

> "David Gethings" <dgething@eu.uu.net> wrote in message
> news:3d99966d$0$8506$cc9e4d1f@news.dial.pipex.com...

>> use ?: which is used for grouping without making backreferences. So the
>> above regex becomes /I like (?:cats|dogs) and my name is (\w+)/. That way
>> only the first element of the array @name is set.
> 
> That works perfectly. In the Rex Swain's HTMLified Perl Ref Guide that I
> sometimes use, it says:
> 
> ?:    Alternation (if-then-else) operator
> 
> Not alot of help that description & certainly wouldn't have led me to the
> conclusion that it's used for grouping without making backreferences. I
> think there must be a lot of things in Perl, like ?:, that could be really
> useful but that I am not aware of. Must do some more reading!

The one you mention is a totally unrelated operator. It does not even
remotely relate to regexes:

    $var = $var ? 2 : 0;

This is the same as
    
    if ($var) {
        $var = 2;
    } else {
        $var = 0;
    }

The ?: we were talking about in this thread is one of the many extended
patterns in regex-context. See "Extended Patterns" in perlre.pod.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 2 Oct 2002 12:58:22 +0100
From: "Bigus" <s.DONTwarhurstSPAM@rl.ac.MEuk>
Subject: Re: How would you... THANKS ALL!
Message-Id: <anen0v$1khm@newton.cc.rl.ac.uk>

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> wrote in
message news:anegls$4iu$1@nets3.rz.RWTH-Aachen.DE...
[..]
> The one you mention is a totally unrelated operator. It does not even
> remotely relate to regexes:
>
>     $var = $var ? 2 : 0;
>
> This is the same as
>
>     if ($var) {
>         $var = 2;
>     } else {
>         $var = 0;
>     }
>
> The ?: we were talking about in this thread is one of the many extended
> patterns in regex-context. See "Extended Patterns" in perlre.pod.

Ahh yes, thanks, I see what you mean.. I was looking in the wrong place in
the reference guide. Ill get there in the end, ya know! ;)

Bigus




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

Date: Wed, 02 Oct 2002 12:30:15 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ignore case in Greek
Message-Id: <slrnaplp5t.2ha.tadmc@magna.augustmail.com>

aragorn <aragorn@freemail.gr.gr> wrote:

> I am trying to create a search form and i have problems with the "i"
> switch in the regular expression statement. The problem is that it
> doesn't work with Greek, 


Do you have your locale set up properly?


   perldoc perllocale


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 02 Oct 2002 12:15:28 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.2 $)
Message-Id: <ArBm9.9629$bY5.39008@bin4.nnrp.aus1.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.2 $)
    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.

    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://mail.augustmail.com/~tadmc/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":

       Please do not use the existence of these guidelines as a
       "license to flame" or other meanness. It is possible that
       a poster is not aware of the things discussed here. Let's
       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" in the 
       very precise sense that they're used in technical conversation 
       (such as you're likely to 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 very unlikely that you're going to 
       get much benefit from using this group.  We're not trying to boss
       you around; we're just trying to convey the point without using 
       a lot 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 is expected regardless of what newsgroup
        you are visiting. Lurking means to simply monitor a newsgroup for a
        period of time until you become very familiar with local customs.
        Think of a newsgroup as foreign culture. Each newsgroup has its own
        specific customs and rituals. Get to know those customs and rituals
        well before you participate. This will help you to 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_group_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.perl.com/CPAN-local/authors/Dean_Roehrich/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* the sections of quoted text
        that your comments apply to. Failure to do this is called "Jeopardy"
        posting because the answer comes before the question.

        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://www.geocities.com/nnqweb/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 <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



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

Date: Wed, 02 Oct 2002 12:29:58 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Question about srand
Message-Id: <3d9ae5e6.2001660255@news.cis.dfn.de>

On Tue, 1 Oct 2002 18:39:50 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>He basically wants to know whether rand uses an architecture-
>independent algorithm.  In fact, the documentation doesn't answer that
>question directly, but I'm pretty sure the answer is "no".

The answer is no :

On Redhat Linux 7.2, perl 5.6.1

perl -e "srand 123; print rand;"

returns 0.0600513969548047

On Windows 2000, perl 5.6.1

it returns: 0.013427734375

-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 2 Oct 2002 11:13:45 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Search Patterns
Message-Id: <psgena.io8.ln@moldev.cmagroup.co.uk>

Alex Reid <reid@surfline.ne.jp> wrote:
> I am trying to do a search pattern
> producing an error for instances of more than one @ mark, lowercase letters
> and not numeric characters

This is not a good set of constraints for a generic email address;
under certain circumstances an email address can contain just about
any ASCII character (including most punctuation). Take a look at RFC822
translations of X.500 addresses if you want one set of scary examples.

The module RFC::RFC822::Address may help you "do it right", but the
fundamental problem is that just about anything containing an @ can be
a plausible email address.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 2 Oct 2002 11:31:17 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Send email from a Database Management Script
Message-Id: <lthena.io8.ln@moldev.cmagroup.co.uk>

Dave <prometheus_au@excite.com.au> wrote:
> I have a flat-file pipe delimted contact database, which is used by
> several scripts on my site.

The CVS module for DBI will let you play with that easily enough. See
DBD::CSV for implementation specifics (assuming you know DBI, of course).

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 02 Oct 2002 13:09:59 +0300
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Set many slots in a hash to the same defined value.
Message-Id: <qbhlpu0okska3ufjumtu6hv7epj05j2ds0@4ax.com>

Tassilo v. Parseval bravely attempted to attach 52 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>
>If I understood you correctly, you want to pass a hash-ref via an
>instance method and initialize each key of this hash (keys are stored in
>the attribute of the object) with the object? How about:
>
>    sub set {
>        my ($self, $hash) = @_;
>        @$hash{ @{$self->{arr}} } = ($self) x @{$self->{arr}};
>    }

Cool, this is what I was looking for (note that I removed 'keys' from
your post). I was missing the parentheses around $self in my trails.

Thanks.


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

Date: 2 Oct 2002 10:11:50 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Set many slots in a hash to the same defined value.
Message-Id: <anegp6$4q5$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Teh (tî'pô):

> Tassilo v. Parseval bravely attempted to attach 52 electrodes of
> knowledge to the nipples of comp.lang.perl.misc by saying:
>>
>>If I understood you correctly, you want to pass a hash-ref via an
>>instance method and initialize each key of this hash (keys are stored in
>>the attribute of the object) with the object? How about:
>>
>>    sub set {
>>        my ($self, $hash) = @_;
>>        @$hash{ @{$self->{arr}} } = ($self) x @{$self->{arr}};
>>    }
> 
> Cool, this is what I was looking for (note that I removed 'keys' from
> your post). I was missing the parentheses around $self in my trails.

Right, keys() made no sense anyway since $self->{arr} was an array-ref not a
hash-ref.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 2 Oct 2002 11:50:10 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Sticky forms without CGI.pm?
Message-Id: <Pine.LNX.4.40.0210021143550.11776-100000@lxplus076.cern.ch>

On Oct 2, Garry inscribed on the eternal scroll:

> I loathe writing second-hand HMTL with CGI.pm but I need the sticky form
> feature. Any ideas how to do it without CGI.pm?

You haven't asked a very coherent question.  There's no compulsion to
generate all of your HTML via CGI.pm's methods just because you're
using it to maintain sticky form parameters.  You _would_ want to use
it to write the relevant parts of the form HTML, though, since that's
where it's going to implement your sticky parameters.

CGI.pm is a standard part of any halfways-recent Perl installation:
why are you so determined to avoid the available solution?

> Do I need to access
> $REQUEST_URI or $QUERY_STRING?

If you want to paint yourself into a corner, then I guess you do.
But I'd counsel against it.  What happens when you find you need to
use POST, or add a file-upload feature, or one of the other reasons
for using multipart form encoding?  All of these can be handled
transparently by CGI.pm.

Quite apart from the risk of reproducing one or more of the standard
bugs in form decoding...



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

Date: Wed, 2 Oct 2002 11:25:46 +0100
From: "Pete Smith" <pete@NOSPAMpopcornwebdesign.co.uk>
Subject: Re: Sticky forms without CGI.pm?
Message-Id: <anehjj$fia$1$8302bc10@news.demon.co.uk>


"Malte Ubl" <ubl@schaffhausen.de> wrote in message:
> No, unless that is really what you want, you shouldn't uri_escape the
> values of an input field. They should be in the encoding of the rest of
> the page.

Correct. You dont want escaped charachters in a field you're going to POST.

Maybe:


  use CGI;
  my $q = new CGI;

  my $inputs = '';
  foreach ($q->param()) {
    $inputs .= qq/<INPUT type="hidden" name="$_" value="/ . $q->param($_) .
qq/">\n/;
  }

  print $inputs;


 ...would work

Pete




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

Date: Wed, 02 Oct 2002 12:53:54 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Sticky forms without CGI.pm?
Message-Id: <3d9aebe6.2003196954@news.cis.dfn.de>

On Wed, 02 Oct 2002 02:12:33 +0100, Garry <none@none.com>
wrote:

>I loathe writing second-hand HMTL with CGI.pm but I need the sticky form
>feature. Any ideas how to do it without CGI.pm? Do I need to access
>$REQUEST_URI or $QUERY_STRING? Parse this with regex's?

Well, it is certainly certainly possible to do without using
CGI.pm, after all , CGI.pm was written without using itself,
but it is such a stupid thing to do, that we don't want  to
spread such counterproductive knowledge.

Why don't you read the CGI.pm source code and find out
how the author did it.  He is a superb programmer,
after all.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 02 Oct 2002 12:32:36 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Top posting (was Re: How can I count files in a directory?)
Message-Id: <3d9ae723.2001977291@news.cis.dfn.de>

>>Rubber Duck <rubberducky703@hotmail.com> wrote:
>>> Top Post????

>Tad McClellan wrote in message ...
>>   http://www.tuxedo.org/~esr/jargon/html/entry/top-post.html
>>   http://www.geocities.com/nnqweb/nquote.html
>>   http://mail.augustmail.com/~tadmc/clpmisc.shtml

On Wed, 2 Oct 2002 09:32:08 +1000, "Tom Beer"
<tom.beer@btfinancialgroup.spamfilter.com> wrote:
>It's a joke, Joyce!

If so, it's a joke that could, and probably has, landed
you in a couple of hundred killfiles.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 2 Oct 2002 04:03:12 -0700
From: adam@acdinternet.com (Adam Knowles)
Subject: Two email things in Perl
Message-Id: <e5778425.0210020303.417cdda@posting.google.com>

Hi,

I need to achieve two different things in Perl. I'm not a great
Perlmonger but I've dabbled enough to know what's possible with the
help of somebody that knows a bit more :)

First thing is this. Most email-valid functions go only as far as
checking the syntax. Is there a snippet out there that could use some
basic POP functions, to verify that the mailbox exists?  i.e. Go so
far as asking the POP server: "Would you accept mail addressed to
this?", without actually sending an email.

The point being that it would cut down on the number of people using
emails with valid syntax but invalid addresses like moose@moose.com.

The second thing is that I've written a very brief script to take an
email message and display it on a webpage. But it only gets the 'From'
line!  I did it by piping email through to my script, rather than a
mailbox, using an alias in sendmail. That part works, and the email is
fed to my script as STDIN. This all works, and my script correctly
writes a file. But it's missing the rest of the email! Here's the
script:

#!/usr/bin/perl -w
#
# $Id: makepage.pl
#

use strict;
use POSIX qw(locale_h strftime);
use Text::Wrap;              # Er for wrapping :)
use Socket;                  # for the inet_aton()
use CGI qw(:standard);

# PROGRAM INFORMATION
# -------------------

BEGIN
{
my $mailprog          = '/usr/sbin/sendmail -oi -t';

my $emailed_text = <STDIN>;

open(fileOUT, ">/www/www.connectpoint.co.uk/web/some_news.htm") or
die("Can't open file for writing: $!");
flock(fileOUT, 2);
print fileOUT <<EOF;
<HTML>

<HEAD>
<TITLE>Hello, world!</TITLE>
</HEAD>

<BODY>
<h3>Here's the message I got sent</h3>
<p>$emailed_text</p>
Thanks for visiting.
</BODY>

</HTML>
EOF

close(fileOUT);

 .. What am I doing wrong?  I suspect it's cuz my prog thinks STDIN has
finished after it gets two new lines (after the 'From' line that it
correctly writes to file). Best way around this?  Do I have to use
MIME::Lite and stuff?

Thanks!


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

Date: 2 Oct 2002 11:31:29 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Two email things in Perl
Message-Id: <aneleh$9cb$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Adam Knowles:

> I need to achieve two different things in Perl. I'm not a great
> Perlmonger but I've dabbled enough to know what's possible with the
> help of somebody that knows a bit more :)
> 
> First thing is this. Most email-valid functions go only as far as
> checking the syntax. Is there a snippet out there that could use some
> basic POP functions, to verify that the mailbox exists?  i.e. Go so
> far as asking the POP server: "Would you accept mail addressed to
> this?", without actually sending an email.
> 
> The point being that it would cut down on the number of people using
> emails with valid syntax but invalid addresses like moose@moose.com.

Mail::CheckUser should come close to that.

> The second thing is that I've written a very brief script to take an
> email message and display it on a webpage. But it only gets the 'From'
> line!  I did it by piping email through to my script, rather than a
> mailbox, using an alias in sendmail. That part works, and the email is
> fed to my script as STDIN. This all works, and my script correctly
> writes a file. But it's missing the rest of the email! Here's the
> script:
> 
> #!/usr/bin/perl -w
> #
> # $Id: makepage.pl
> #
> 
> use strict;
> use POSIX qw(locale_h strftime);
> use Text::Wrap;              # Er for wrapping :)
> use Socket;                  # for the inet_aton()
> use CGI qw(:standard);
> 
> # PROGRAM INFORMATION
> # -------------------
> 
> BEGIN
> {
> my $mailprog          = '/usr/sbin/sendmail -oi -t';
> 
> my $emailed_text = <STDIN>;

Here's the problem. This stores only the first line in the variable. To
get it entirely, undef $/ temporarily:

    my $emailed_text = do { local $/; <STDIN> };

[...]

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 02 Oct 2002 13:41:54 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Two email things in Perl
Message-Id: <anepdb$ahl$1@news.dtag.de>

Adam Knowles wrote:
> Hi,
> 
> I need to achieve two different things in Perl. I'm not a great
> Perlmonger but I've dabbled enough to know what's possible with the
> help of somebody that knows a bit more :)
> 
> First thing is this. Most email-valid functions go only as far as
> checking the syntax. Is there a snippet out there that could use some
> basic POP functions, to verify that the mailbox exists?  i.e. Go so
> far as asking the POP server: "Would you accept mail addressed to
> this?", without actually sending an email.

The only satisfactory way is to actually send an email containing some 
kind of session id and require the user to either click a link or reply 
to the email.

bye,
->malte



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

Date: Wed, 2 Oct 2002 13:25:40 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Two email things in Perl
Message-Id: <4koena.nk9.ln@moldev.cmagroup.co.uk>

Adam Knowles <adam@acdinternet.com> wrote:
> Here's the script:

Missing right curly or square bracket at makepage.pl line 40, at end of line
syntax error at makepage.pl line 40, at EOF
Execution of makepage.pl aborted due to compilation errors.


> BEGIN
> {

What do you intend these two lines to do? I'd remove them

> my $emailed_text = <STDIN>;

This reads the first line from STDIN...

> <p>$emailed_text</p>

 ...which is later interpolated into your file

> What am I doing wrong?

Four things spring to mind:

1.  Your code as posted is not exactly the same as your script. Use cut
    and paste. Don't copy-type!

2.  If you want to read the entire of STDIN into a scalar you need
    something like this:

    	my $emailed_text = join ('', <STDIN>);

3.  If you want the line breaks to appear (so the email is formatted
    "correctly") then you need either to surround the text with
    <pre>...</pre> instead of <p>...</p>, or join() the lines from STDIN
    with '<br>':

    	my $emailed_text = join ('<br>', <STDIN>);

4.  In both cases for #3 you will potentially interpolate nasty HTML
    and/or ECMAScript into your web page. Consider what would happen if
    the email message body contained HTML or <SCRIPT/> directives.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 02 Oct 2002 12:30:15 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Two email things in Perl
Message-Id: <slrnaplpks.2ha.tadmc@magna.augustmail.com>

Adam Knowles <adam@acdinternet.com> wrote:

> First thing is this. Most email-valid functions go only as far as
> checking the syntax.


   perldoc -q mail

      "How do I check a valid mail address?"


> The second thing is that I've written a very brief script to take an
> email message and display it on a webpage. But it only gets the 'From'
> line!

> my $emailed_text = <STDIN>;


The input operator in scalar context gives you one line, so
that is all you are getting.

The input operator in list context gives you all of the lines:

   my $emailed_text = join '', <STDIN>;

or, better:

   my $emailed_text;
   { local $/;  # enable slurp mode
      $emailed_text = <STDIN>;
   }



> flock(fileOUT, 2);


You should import the constants rather than hard code them.

You should check the return value.



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 2 Oct 2002 05:33:27 -0700
From: cubicle584@mailandnews.com (Software Scavenger)
Subject: Re: Use Java! Was: becoming a better programmer
Message-Id: <a6789134.0210020433.28d20e75@posting.google.com>

Donald Fisk <hibou00000nospam@enterprise.net> wrote in message news:<3D9A32C4.26008645@enterprise.net>...
> (defun fac (n)
>   (if (zerop n)
>       1
>     (* n (fac (1- n)))))
> 
> (defun fac (n)
>   (do ((i n (1- i))
>        (result 1 (* i result)))
>       ((= i 1) result)))
> 
> (defun fac (n)
>   (collect-sum (scan-range :from 1 :upto n)))

   (defun fac (n)
      (apply '* (iota n)))


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

Date: Wed, 02 Oct 2002 10:48:21 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: why does where matter?
Message-Id: <3d9acd9b.312319069@news.erols.com>

"~greg" <gm@magpage.com> wrote:

| My question is:  why doesn't it work 
| when the array reference is declared *after* the the sub definition?  

Because my() sets their scopes.

| use strict;
| 
| my $Test1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]];

$Test1 's scope begins here.

| sub PrintArray
| {
|   my $a = shift;
|   my $a_ = eval $a;

Weird.

|   print "my $a=\n[\n",    join(  ",\n",  map { '  ['  . join( ',',  @{$_} ) . ']' }  @{$a_}  ),    "\n];\n\n" ;
| }
| 
| my $Test2 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]];
 
$Test2 's scope begins here.

| PrintArray( '$Test1' );
| PrintArray( '$Test2' );

Trying to bounce $Test2 up to the sub with this strange method of
indirection fails because $Test2 does not exist within the scope of the
sub.


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

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.  

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

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 3900
***************************************


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