[22846] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5067 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 06:05:48 2003

Date: Tue, 3 Jun 2003 03:05:07 -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, 3 Jun 2003     Volume: 10 Number: 5067

Today's topics:
        "Standard" modules missing in ActivePerl <goedicke@goedsole.com>
    Re: "Standard" modules missing in ActivePerl <goedicke@goedsole.com>
    Re: Access variable in caller's scope (or alternate sol (Anno Siegel)
    Re: Adding to @INC <thepotplants@yahoo.com>
    Re: APP: perl script editor (Alexander Romanov)
    Re: Comments/Help on Ring Element Id Subroutine? <email_entropy123@yahoo.com>
    Re: Help!: Returning an Array or Hash from inside a nes <email_entropy123@yahoo.com>
    Re: Help: Sort HOH by value? <email_entropy123@yahoo.com>
    Re: NEWBIE: Pls help or point.  Enumerating dirs, findi <nothanks@nospamreallythanks.com>
    Re: NEWBIE: Pls help or point.  Enumerating dirs, findi <jurgenex@hotmail.com>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: regexp to negate 2 chars at once <bigj@kamelfreund.de>
    Re: Resolve UNIX environment variable within an array <jurgenex@hotmail.com>
    Re: Resolve UNIX environment variable within an array <mgjv@tradingpost.com.au>
    Re: Return Array from a Nested Subroutine? <email_entropy123@yahoo.com>
        Still puzzled, file handles and infinite loops (fatted)
    Re: Still puzzled, file handles and infinite loops <g4rry_short@zw4llet.com>
    Re: test <no@spam.for.me.invalid>
    Re: uninitialized value in eval block? <bart.lateur@pandora.be>
    Re: Using "eval" with "my", works up to a point, then . <bart.lateur@pandora.be>
        Weird Perl Performance Issues (Geoffrey Zhu)
    Re: Weird Perl Performance Issues <bigj@kamelfreund.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Jun 2003 09:38:10 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: "Standard" modules missing in ActivePerl
Message-Id: <m3of1f5wn5.fsf@mail.goedsole.com>

Dear Y'all - 

I've written a profiler for an awful reporting language called SQR.  I
want to distribute it as an executable so I'm installing ActiveState
5.6.1 build 635.  Several of the modules I consider standard, though
not core, in the UNIX world don't appear to exist (e.g. Time::Local,
Getopt::std).  Am I missing something.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

Collaboration: "Get out of my f***ing way".

		- William Goedicke


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

Date: Tue, 03 Jun 2003 09:41:58 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: "Standard" modules missing in ActivePerl
Message-Id: <m3k7c35wgt.fsf@mail.goedsole.com>

Dear Y'all - 

Oops, my bad.

I <goedicke@goedsole.com> wrote:

> Several of the modules I consider standard, though
> not core, in the UNIX world don't appear to exist (e.g. Time::Local,
> Getopt::std).  Am I missing something.

They're there, but the following returns nothing.

ppm> query --nocase dumper

Go figure.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

Don't force it; get a bigger hammer.

		- Al Dodge


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

Date: 3 Jun 2003 08:56:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Access variable in caller's scope (or alternate solution?)
Message-Id: <bbhnr7$9qo$1@mamenchi.zrz.TU-Berlin.DE>

JS Bangs  <jaspax@u.washington.edu> wrote in comp.lang.perl.misc:
> Anno Siegel sikyal:
> 
> > JS Bangs  <jaspax@u.washington.edu> wrote in comp.lang.perl.misc:
> >
> > You can probably use a closure to pass parameters into the sub
> > without the user's cooperation.  See below.
> >
> > > Conceptually, the whole process runs like this:
> > >
> > > # User script
> > > # The function I'm worried about is metathesize(), provided to make life
> > > # easier for the user
> > >
> > > $rules = new Lingua::Phonology::Rules;
> > > $rules->add_rule( Swap => {
> > > 	direction => 'rightward',
> > > 	do => sub { metathesize($_[0], $_[1]); }
> >
> > Make that
> >
> >         do => sub { metathesize($_[0], $_[1], 'rightward') },
> >
> > > });
> >
> > Now metathesize will be called with three parameters instead of two,
> > the third being whatever was deposited there when the rule was entered
> > into the Rules object.
> 
> But this defeats the purpose. The do => sub {} statement is part of what
> the user declares, and I explicitly do not want to make the user have to
> pass the direction  as an argument. Sorry if this wasn't clear from the
> start.

What still isn't clear is who sets the "direction" value and when does
this happen.  Apparently at some point the user has to type in
"do => sub { metathesize($_[0], $_[1])" but not "direction => 'rightward'".
So who contributes "direction => 'rightward'"?

Or is it that the user *does* declare the direction, but you want her
to do it only once and not for every rule she adds?  The solution to
your problem hinges on that point, which isn't quite clear yet.

> > Change this to
> >
> >         my ($seg1, $seg2, $dir) = @_;
> >
> > Now $dir will be "rightward", or whatever was put there when add_rule
> > was executed.
> >
> > > 	# HERE the proper action depends on what's in $dir, from
> > > 	# Lingua::Phonology::Rules
> > > } # end metathesize
> >
> > Whether you still need to keep "direction" in the rules hash separately
> > can't be said from the example code.  The closure doesn't need it.
> 
> Yes, my explanation wasn't completely clear about the usage of this
> program, and what you've suggested does the opposite of what I was hoping
> to do.
> 
> Every rule inside a Lingua::Phonology::Rules object has a direction
> parameter, which is used to determine the order in which Rules.pm iterates
> over the arguments passed to it.

Okay, but who decides what the direction is, and when?

>                                  What actually happens to those arguments
> is determined by the 'do' parameter. In almost all cases the code
> reference passed as the 'do' parameter does not depend on the direction,
> and doesn't care what the direction is. Metathesis is a special case: it
> involves changing the order of arguments, and can potentially cause an
> infinite loop by repeatedly switching the same two arguments. It could
> also move the same argument repeatedly, causing something to go from the
> very beginning to the very end.

This explains why the direction parameter is needed in some cases, but
not where it comes fro.

> I hope to make the metathesis() function avoid both of these bad outcomes,
> but in order to do this it needs to know what direction Rules.pm is
> iterating across its arguments. I'd also like to do this invisibly, with
> no extra effort on the user's part. To accomplish these goals, it looks
> like I'll have to break down and write 'our local $dir' in Rules.pm, then
> let metathesis() break in to get that variable. This would normally be a
> Bad Thing, but it looks to be the only way to get the magic I want.

I don't see why you necessarily need a package variable for that.
You could use a file scoped lexical "my $dir", plus a class method
to set the variable.  It doesn't even have to be file-scoped:

    {  # direction-sensitive transformations
        my $dir;

        sub set_direction { $dir = shift }

        sub metathesize {
            my ( $x, $y) = @_;
            # ....
            if ( $dir eq 'leftwards' ) {
                # ...
            }
            # ...
        }

        # more direction-sensitive transformations
    }

You will have to know when and how to call set_direction(), but
the effect on metathesize() will be the same as a package variable
$dir.

Anno


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

Date: Tue, 3 Jun 2003 16:25:39 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Re: Adding to @INC
Message-Id: <drVCa.6954$JA5.121433@news.xtra.co.nz>

Ok guys thank you.
I did have a go at the perl docs but I'm still so 'green' that I'm not
findig what I want...

On the upside. :)

The cause of the my problem was actually because I had 2 versions of perl on
my machine.
I originally had Activestate 5.6 installed, but unfortunately my paths got
clobbered when I installed Oracle 817 on Thursday.
(perl -v gave a very odd result... and gave it away...)

I found that under the oracle home dir, it installed Apache and under that
it decided to install perl 5.005.
I clobbered both and reinstalled 5.6, and now my program runs without the
errors.

Thanks again for your help. (I promise to try reading more docs next time ;)

Regards

Pete

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bbh2gp$9drf4$1@ID-184292.news.dfncis.de...
> ThePotPlants wrote:
> > use DBI 'C:\Perl\site\lib\' ;
>
> No. This is how you make use of lib.pm to change @INC:
>
>      use lib 'C:/Perl/site/lib';
>      use DBI;
>
> > Is there another way of simply adding the directory to the other
> > paths?
>
> Can it be simpler than that? :)
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>




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

Date: 3 Jun 2003 01:22:34 -0700
From: support@sannysoft.com (Alexander Romanov)
Subject: Re: APP: perl script editor
Message-Id: <7f5f41b7.0306030022.30193ebd@posting.google.com>

I think  the best editor for Windows is SannySoft Perl Editor. All
about it you can find here: www.sannysoft.com/products/perleditor .


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

Date: Mon, 02 Jun 2003 23:47:11 -0500
From: "ent123" <email_entropy123@yahoo.com>
Subject: Re: Comments/Help on Ring Element Id Subroutine?
Message-Id: <pan.2003.06.03.04.47.08.798573@yahoo.com>


> Given a solution to question 8, questions 1-4 and 7 can all
> be easily (but not necessarily efficiently) solved by creative application
> of 8.  Heck, I bet 5 and 6 can be too, if I put my mind to it.
> 
> Xho

:) Xho, thanks for the comments. I've got the idea now, now I'm mostly
struggling with the programming part. Don't know why it took so long, I
think I was trying to do too much at once.

Here are my major problems :)

a) My 'rings' are trapped in a 'if statement' in a subroutine. (I can print them to screen,
but can't get them back to main as arrays, not sure how I would name them
as hashes - multiple rings w/same key).

b) I haven't managed to find a way to force perl evaluate a two degree
atom as the first element of a DFS. (When a 3 degree atom is first the DFS
doesn't work.

Other than that I think I'm out of the woods....

Thanks man,
entropy


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

Date: Mon, 02 Jun 2003 23:53:30 -0500
From: "ent123" <email_entropy123@yahoo.com>
Subject: Re: Help!: Returning an Array or Hash from inside a nested subroutine?
Message-Id: <pan.2003.06.03.04.53.29.809797@yahoo.com>


> 
>      ($result, @node) = dfs_visit( ... );
> 
> Or maybe pass it as a reference...
> 
> / Gunnar
 .....hmmm...

Thanks man, based on this I guess I need to pass those values as a HoA
which continues to grow until the end of the subroutine. Each ring results
in a new key/array pair.


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

Date: Mon, 02 Jun 2003 23:59:02 -0500
From: "ent123" <email_entropy123@yahoo.com>
Subject: Re: Help: Sort HOH by value?
Message-Id: <pan.2003.06.03.04.59.01.986672@yahoo.com>

Xho & Gunnar,

Thanks, tomorrow morning I'll try this out, I'll see how the ideas apply
to a HoH and, come to think of it, I'd rather sort by $HoH{$key1}{$key2}
where the first hash in has the least number of keys.

Three $key2's give the dfs routine fits - fused rings...

Thanks,
entropy



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

Date: Tue, 03 Jun 2003 04:25:03 GMT
From: Michael <nothanks@nospamreallythanks.com>
Subject: Re: NEWBIE: Pls help or point.  Enumerating dirs, finding files?
Message-Id: <0d8odvk0h5g0nm3homb8c3qa8b7rftcf1u@4ax.com>

Thank you both, very much.

The books I have explain how to set file permissions, determine how old it is and how to change the timestamp.  I think
I have the wrong books.  

If I could impose upon you once again, where might I find the Perl FAQ?  And, although I don't want to offend anyone in
any way, nor cause any flame wars, where did you find out about File::Copy and File::Find?  They do not appear to be
referenced in the books I chose to buy.  Do you mind recommending a book that talks about these things?

Thank you again,
Michael




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

Date: Tue, 03 Jun 2003 04:31:59 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: NEWBIE: Pls help or point.  Enumerating dirs, finding files?
Message-Id: <3xVCa.10308$JW6.844@nwrddc02.gnilink.net>

Michael wrote:
> If I could impose upon you once again, where might I find the Perl
> FAQ?

On your very own hard drive. It comes with any Perl installation.

Try
- perldoc perldoc
- perldoc perlfaq
- perldoc -q <KEYWORD>
where <KEYWORD> is some keyword you are looking for.

> And, although I don't want to offend anyone in any way, nor
> cause any flame wars, where did you find out about File::Copy and
> File::Find?  They do not appear to be referenced in the books I chose
> to buy.  Do you mind recommending a book that talks about these
> things?

They come as standard Perl modules. And they are mentioned in this NG about
5 times a week.

jue




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

Date: Tue, 03 Jun 2003 02:22:27 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <KvOdnfNLHcku0UGjXTWcpg@august.net>

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.4 $)
    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":

       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 

    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_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.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
        "Jeopardy" (because the answer comes before the question), or
        "TOFU".

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



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

Date: Tue, 03 Jun 2003 06:06:19 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: regexp to negate 2 chars at once
Message-Id: <pan.2003.06.03.04.01.05.297426@kamelfreund.de>

Dan Jacobson wrote at Tue, 03 Jun 2003 06:15:26 +0800:

>> Look for the (?! ) operator in perldoc perlre
> 
> I did. Now what?

Now, you can try something like
s/(?!bw)..//;


Greetings,
Janek


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

Date: Tue, 03 Jun 2003 04:34:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Resolve UNIX environment variable within an array
Message-Id: <lzVCa.10316$JW6.35@nwrddc02.gnilink.net>

adans wrote:
> I have problem to resolve any UNIX environment variables when the
> environment variable is the content of an array.  I understood to use
> $ENV(env_variable) for resolving the environment variable if it is a
> scalar.

Actually it would be $ENV{env_variable}.
And I have no idea what you mean by "env variable is the content of an
array".
Which shell/OS supports that?

jue




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

Date: Tue, 03 Jun 2003 05:54:28 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Resolve UNIX environment variable within an array
Message-Id: <slrnbdoe0k.1lr.mgjv@verbruggen.comdyn.com.au>

On 2 Jun 2003 21:00:42 -0700,
	adans <adans@billiongroup.com> wrote:
> I have problem to resolve any UNIX environment variables when the
> environment variable is the content of an array.  I understood to use
> $ENV(env_variable) for resolving the environment variable if it is a
> scalar.

That would be $ENV{variable_name}.

There is no such thing as an environment variable which has the
contents of an array. An environment variable is simply a key-value
pair, where both key and value are simple strings. In Perl, that value
is always a scalar.

However, some shells support shell variables that are (or act as)
arrays. They are however, not environment variables, and you can't
pass them to Perl that way. If the shell encodes that array in some
way in an environment variable, you will need to find out how that
encoding works, and decode it in Perl (probably with split). That is,
however, not a Perl issue, but a shell issue.

Martien
-- 
                        | 
Martien Verbruggen      | If at first you don't succeed, destroy all
Trading Post Australia  | evidence that you tried.
                        | 


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

Date: Mon, 02 Jun 2003 23:55:40 -0500
From: "ent123" <email_entropy123@yahoo.com>
Subject: Re: Return Array from a Nested Subroutine?
Message-Id: <pan.2003.06.03.04.55.40.496666@yahoo.com>

Bob & Eric,

Thanks for looking the code over, after 'use strict' I discovered just how
many problems I really had :).

Mostly fixed, just need to figure out how to ensure the first key checked
has only two other nodes connected to it, three node first keys are
possible and give the dfs routine fits.

Thanks,
entropy


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

Date: 3 Jun 2003 02:09:01 -0700
From: fatted@yahoo.com (fatted)
Subject: Still puzzled, file handles and infinite loops
Message-Id: <4eb7646d.0306030109.78371808@posting.google.com>

Thanks for previous help (posted under "scope of variable"). But I'm
still puzzled. Looking at the following script:

use warnings;
use strict;

open(OUT,">>","test.log");

while(1)
{
        sleep(2);
        my($seconds, $minutes, $hours, $day_of_month, $month, $year,
$wday, $yday, $isdst) = localtime(time);
        print OUT (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
        print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
}

When this is run, it prints the time to the screen every 2 seconds.
Eggcellent. However it doesn't write the time to the file at all
(although the file is created, as expected).

Now try the following script:

use warnings;
use strict;

while(1)
{
        sleep(2);
        my($seconds, $minutes, $hours, $day_of_month, $month, $year,
$wday, $yday, $isdst) = localtime(time);
        open(OUT,">>","test.log");
        print OUT (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
        print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
}

Again prints time to screen every 2 seconds, and now also writes to
file. *Except*, the file is 2 seconds (1 loop?) behind. So As soon as
time 10:58:03 is printed to screen, I hit ^C, looking in file and last
time printed is 10:58:01. Looking at code the write to the file is
before the write to the screen, so I couldn't have just got lucky
(stopping program between the 2 prints) with where I ^C'ed.

From previous discussion, I understand (hopefully :) that there
shouldn't be a difference between where the open command is called,
the file handle should still be available in the while loop, so why
does the program perform differently?
Why is the write to the file appear to be behind the write to STDOUT?


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

Date: Tue, 03 Jun 2003 10:56:38 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Still puzzled, file handles and infinite loops
Message-Id: <bbhrj4$a4f$1$830fa79d@news.demon.co.uk>

fatted wrote:

> Thanks for previous help (posted under "scope of variable"). But I'm
> still puzzled. Looking at the following script:
> 
> use warnings;
> use strict;
> 
> open(OUT,">>","test.log");
> 
> while(1)
> {
>         sleep(2);
>         my($seconds, $minutes, $hours, $day_of_month, $month, $year,
> $wday, $yday, $isdst) = localtime(time);
>         print OUT
>         (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
>         print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
> }
> 
> When this is run, it prints the time to the screen every 2 seconds.
> Eggcellent. However it doesn't write the time to the file at all
> (although the file is created, as expected).
> 
> Now try the following script:
> 
> use warnings;
> use strict;
> 
> while(1)
> {
>         sleep(2);
>         my($seconds, $minutes, $hours, $day_of_month, $month, $year,
> $wday, $yday, $isdst) = localtime(time);
>         open(OUT,">>","test.log");
>         print OUT
>         (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
>         print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
> }
> 
> Again prints time to screen every 2 seconds, and now also writes to
> file. *Except*, the file is 2 seconds (1 loop?) behind. So As soon as
> time 10:58:03 is printed to screen, I hit ^C, looking in file and last
> time printed is 10:58:01. Looking at code the write to the file is
> before the write to the screen, so I couldn't have just got lucky
> (stopping program between the 2 prints) with where I ^C'ed.
> 
> From previous discussion, I understand (hopefully :) that there
> shouldn't be a difference between where the open command is called,
> the file handle should still be available in the while loop, so why
> does the program perform differently?
> Why is the write to the file appear to be behind the write to STDOUT?


In the second one, you're not closing the file once you've written to it.
Add a "close OUT;" statement within the end of the loop, and it will work
as you expect.

For the first loop, the file never gets closed, and hence presumably never
gets saved (or written to, not sure which).

So why does the second one work, then? you may ask. Well if memory serves,
when you open a filehandle that is already open, it closes it for you
first.

HTH,

Garry




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

Date: Tue, 03 Jun 2003 08:59:05 GMT
From: "Nils Petter Vaskinn" <no@spam.for.me.invalid>
Subject: Re: test
Message-Id: <pan.2003.06.03.08.59.07.615660@spam.for.me.invalid>

On Mon, 02 Jun 2003 13:27:59 -0700, DA wrote:

> testing. pl. ignore

No I won't. There are plenty of test groups which is the place for test
posts that you want ignored. Was it really too much work to use one?

If you have some legitimate reason (lazyness isn't) to post tests outside
the test groups you should explain it in your test post.

That aside, welcome to the group.

NPV


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

Date: Tue, 03 Jun 2003 08:52:28 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: uninitialized value in eval block?
Message-Id: <fdoodvk8mog0353229r6iifgnsql64vg1h@4ax.com>

Benjamin Goldberg wrote:

>It points to the 32nd line within a string which was passed to eval(),
>not to the 18th or 32nd line of your eval BLOCK.

It'd be nice if perl were also to say on what line that eval() was
called.

-- 
	Bart.


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

Date: Tue, 03 Jun 2003 08:57:24 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Using "eval" with "my", works up to a point, then ...
Message-Id: <floodvctf36cfl0h8vlglr4cneas7r7aj4@4ax.com>

grazz@pobox.com wrote:

>> $a = 4                               ;
>
>Which means that this is a package variable ($main::a) and,
>like any other undeclared, unqualified package variable, it 
>will break strict 'vars'.

You forgot that $a (and $b) is special. Think sort blocks.

Use another variable's name to come to some conclusion. Like $A. :-)

-- 
	Bart.


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

Date: 2 Jun 2003 21:45:02 -0700
From: bnezbj1q02@sneakemail.com (Geoffrey Zhu)
Subject: Weird Perl Performance Issues
Message-Id: <c6e93690.0306022045.34328192@posting.google.com>

Hello Folks,

I encountered a very interesting perl performance issue recently.

I have three functions on an object, fn_a, fn_b, fn_c. I have verified
that they do not interfere with each other. The following are highly
interesting:

1. If you call three functions together in a loop, like the following,
it takes 26 seconds.

foreach my $o ( values %My::Objects ) 
{
    $o->fn_a();
    $o->fn_b();
    $o->fn_c();
}

2. If you call the three functions separately, like the following, it
takes a total of 4 seconds.

#1 sec
foreach my $o (values %My::Objects ) 
{
    $o->fn_a();
}
#1 sec
foreach my $o (values %My::Objects ) 
{
    $o->fn_b();
}
#2 sec
foreach my $o (values %My::Objects ) 
{
    $o->fn_c();
}


The question is why the execution time reduces so much if I put the
function calls in separate loops. Any hint?

Thanks,
G


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

Date: Tue, 03 Jun 2003 05:48:56 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Weird Perl Performance Issues
Message-Id: <pan.2003.06.03.03.48.54.460937@kamelfreund.de>

Geoffrey Zhu wrote at Mon, 02 Jun 2003 21:45:02 -0700:

> I encountered a very interesting perl performance issue recently.
> 
> I have three functions on an object, fn_a, fn_b, fn_c. I have verified
> that they do not interfere with each other. The following are highly
> interesting:
> 
> 1. If you call three functions together in a loop, like the following,
> it takes 26 seconds.
>
> [...]
>
> 2. If you call the three functions separately, like the following, it
> takes a total of 4 seconds.
>
> [...]
>
> The question is why the execution time reduces so much if I put the
> function calls in separate loops. Any hint?


That's odd. Show us the full code.
(Normally you won't need 4 seconds only to call some functions).
We can only guess what's going on if we know what the hash consists of and
what the functions do.


Greetings,
Janek


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

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


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