[29181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 425 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 11 06:09:40 2007

Date: Fri, 11 May 2007 03:09:03 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 May 2007     Volume: 11 Number: 425

Today's topics:
    Re: Any way to access global variable in Perl script fr <Michael.Yxf@gmail.com>
    Re: DBD::Oracle, tracing, and stored procedures... (Heinrich Mislik)
    Re: How to concatenate cookies <nobull67@gmail.com>
        How to restart all hashes and arrays halfway through sc <csoon@xilinx.com>
    Re: I'd like to create an array of unique values <sujay.tukai@gmail.com>
        Identify if a scalar is int, double or text <klaus03@gmail.com>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: warnings dilemma <nobull67@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 11 May 2007 01:15:20 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Any way to access global variable in Perl script from one module file?
Message-Id: <1178871320.097552.79070@w5g2000hsg.googlegroups.com>

On May 11, 2:43 pm, Brian McCauley <nobul...@gmail.com> wrote:
> On 11 May, 06:03, Michael Yang <Michael....@gmail.com> wrote:
>
> > On May 11, 1:07 am, Brian McCauley <nobul...@gmail.com> wrote:
> > > On May 10, 1:38 pm, Michael Yang <Michael....@gmail.com> wrote:
> > > > How can I call Testrunner.pl from main.pl without spawning a separate
> > > > child process?
> > > You could do() it. However this would possibly give odd effects if you
> > > try to call Testrunner.pl more than once from main.pl.
> > I am thinking about using 'require' to do this:
> > @ARGV = ();
> > require 'Testrunner.pl';
>
> > In this way, the variable defined in the main script is in the same
> > context as the Testrunner.pl, and could be accessed from the module
> > file.
>
> Yes that's what I said. Well I said do() not require(). But the only
> difference in this conext is that main.pl _cannot_ run Testrunner.pl
> more than once.
>
> > But I found it slows the harness greatly, the performance is lowered.
>
> That seems highly counter-intuative. I would expect it to be a little
> faster as you are only loading perl once.
>
> How are you observing this? Is it possible that it's not the tests
> that are running slowly but rather something like an output buffering
> issue?
>
> > How to leaverage on this?
>
> Well the bunderbus thing would be to make a copy of the whole thing,
> main.pl, Testrunner.pl and at least one test case and check you still
> see the difference. Then cut bits out progressively checking at each
> stage that you still see the difference.
>
> Eventually you'll have a minimal but complete test case to illustrate
> the behaviour. If but this time you've not spotted what's happening
> then you should post the three files (which by now should be <20 lines
> each).

Thanks for your pointing it out, Brian.
There is indeed the output buffering codes in the script, but I
thought it works fine.
Since it's a harness containing serveral large scripts, that I can't
paste each piece of the codes, so I only put the key parts of the
codes to simply illustrate what I am doing. Also the codes that might
have relationship with output buffering.

### my main.pl script ####
### <codes omitted>####
## Start calling the Testrunner.pl ###
@ARGV = ( "$testcase",     ###The file with list of testcases in xml
format
                    "$paramFile",  ###The file containing the
configuration data
                   "$logfile");         ###The file that log data is
written to.

do "$<path to runner>/Testrunner.pl";
if ($@){
     #### codes to deal with errors ####
}
###<codes omitted>####
### End of main.pl script ###

#### Testrunner.pl script #######
### <codes to process parameters passed by main.pl>  omitted###
### Set the autoflush to ON ####
$| = 1;
### <codes to process list of testcases>  omitted###
### Start to run the testcase subroutines in each module####
foreach my $sr (@routines)
{
    select STDOUT;  #route print statements to STDOUT
    $logHandler->write($sr)  # write the testcase info into logfile,
defined in another module
    print "\n\t Executing => $sr";

    select $logFileHandle;   # route print statements to the logfile,
the one passed into by  main.pl

    eval
    {
        no strict "refs";
        ($sr) -> ($params);   #execution of the subroutines contained
in each testcase module
    }
}
#### <codes dealing with the rest> omitted ####
#### End of Testrunner.pl #####

### The module for one testcases, case1.pm#####
package case1;
#### <codes dealing with the member variables> omitted ####
sub test1
{
    ####<codes omitted> ####
    ###This will be directed to the logfile specified by the "select
$logFileHandle" in Testrunner.pl#####
    print "Executing the test1...\n";
    $output = `...`;    ## There is one child process spawned here, I
saved the output into one variable.
    ### <rest of codes> omitted ####
}
### <codes left> omitted ####
1;
#####End of case1.pm #######

I just looked throught, and think these parts might have something
with output buffering issue if there is any.
These work fine and fast by invoking Testrunner.pl by spawning a child
process, as discussed previously, except for the problem that the
variable in main.pl can not be accessed from case1.pm.

I am not sure which will affect and cause the buffering issues. If you
have any simple example, could you show me one that might block the I/
O that I could look into it?

Thanks so much!




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

Date: 11 May 2007 08:22:23 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: DBD::Oracle, tracing, and stored procedures...
Message-Id: <464427bf$0$28520$3b214f66@usenet.univie.ac.at>
Keywords: dbi dbd oracle tracing

In article <slrnf444qn.mki.urban@noisy.spielwiese.de>, ru@vakuum.de says...
>
>#======================================
># permutation 1:
>#======================================
>
>CODE>
>
>my $sql = qq{
>        BEGIN
>        sys.dbms_system.set_ev(46, 53017, 10046, 4, '');
>        END;
>};
>$sql = $DBH->quote($sql);

This doesn't do any good. $DBH->quote returns one single string constant in
SQL syntax. Look closely at the error. Your statement starts with 'BEGIN ... instead of plain BEGIN ...

>my $rv = $DBH->do($sql);
>
>RESULT>
>
>DBD::Oracle::db do failed: ORA-00900: invalid SQL statement (DBD ERROR:
>OCIStmtExecute) [for Statement "'
>                BEGIN
>                sys.dbms_system.set_ev(46, 53017, 10046, 4, '''');
>                END;
>        '"] at ./trace.pl line 72.

Can't see any error in both the other permutations. I have called procedures 
this way and it worked.

Cheers

Heinrich

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



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

Date: 11 May 2007 00:28:31 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: How to concatenate cookies
Message-Id: <1178868511.445458.288020@n59g2000hsh.googlegroups.com>

On 11 May, 06:09, dr_phill...@yahoo.com wrote:
> On May 10, 11:35 pm, "Mumia W." <paduille.4061.mumia.w
>
> +nos...@earthlink.net> wrote:
> > You can put several values into a single cookie like so:
>
> > my $cookie = $query->cookie(
> >         -domain => $domainname,
> >         -name => 'customfields',
> >         -value => \@custom_fields
> >         );
> > print $query->header(-cookie => $cookie);
>
> > Read the CGI docs again: perldoc CGI
>
> Thanks, but I am actually looking for each cookie to be seperate, so
> have multiple cookies in one variable $cookie. The docs says:
>
> you may concatenate the cookies together with ``; ''
>
> I am not sure what those characters mean ``; " ?

I'd guess they'd mean a literal semicolon (whereas you had a comma).

But one of my top rules of programming is "always use the most natural
representation of things". The most natural type of variable to
represent a list of things is an array (not a delimited string).

my @cookie_custom_fields;
for my $j ( 0 .. $#custom_fields ) {
        push @cookie_custom_fields => $query->cookie(-domain=>
$domainname,
                        -name=>"custom$j",
                         -value=>"$in_field[$j]" );
}
print $query->header(-cookie=>\@cookie_custom_fields);



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

Date: Fri, 11 May 2007 15:26:08 +0800
From: "Ken Soon" <csoon@xilinx.com>
Subject: How to restart all hashes and arrays halfway through script
Message-Id: <f2160f$b9q1@cnn.xsj.xilinx.com>

Hi,
I am using dynamic arrays and hashes to store data. The names of the hashes 
and arrays changes to a certain groups of names and there are alot of names.

Then i did some operations on this data with file::find, write to some files 
and others....
However, as i continue on to another new operation on those hashes and 
arrays, somehow all the values are gone or different (I'm not sure yet 
whether is gone or different as I'm having trouble debugging to find out the 
confirmed erroneous output)
Thus I am hoping if there such a thing to reset everything before i start on 
that next operation. (as if i am restarting the script at that point)

Hmm all this sound abit weird though but i guess it is because haven't been 
able to debug the problem.

hope my point is clear :X 




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

Date: 11 May 2007 02:43:24 -0700
From: "sujay.tukai@gmail.com" <sujay.tukai@gmail.com>
Subject: Re: I'd like to create an array of unique values
Message-Id: <1178876603.949338.260100@n59g2000hsh.googlegroups.com>

On May 9, 8:29 pm, Mr P <MisterP...@gmail.com> wrote:
> Sounds just like keys %h don't it.
>
> Starting with
>
> $_ =
> "cat
> man
> dog
> mouse
> man
> man
> ";
>
> I want to end up with
>
>   [cat man dog mouse]
>
> My approach is:
>
>  my @s = split /\n/;
> # unique-afy it!
>  my %s;
>  @s{@s} = @s;
>  @s = keys %s;
>
> My PREFERENCE is to not have to involve both a hash and an array, and
> also to not have to include a non-native lib module.
>
> Is there a syntax I can use to just work with the hash and populate
> the keys-only directly from the split? I don't really care what the
> values are. I don't even care if they are undef.
>
> Thank-You, Peristas,
>
> MP


I feel this is the shortest answer to ur query.

perl -e '$_ = "dog
man
dog
cat
mouse
man
man";
my %tmp; my @a;
@a = map {$tmp{$_}=$_ if(! $tmp{$_});} split("\n",$_);
print @a;'







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

Date: 11 May 2007 02:03:18 -0700
From: Klaus <klaus03@gmail.com>
Subject: Identify if a scalar is int, double or text
Message-Id: <1178874197.967635.164880@n59g2000hsh.googlegroups.com>

Hello,

I have a list of 4 scalars
my @L = (3, '3', 3.0, '3.0');

The first is obviously an int, the second is text, the third a double
and the last is text again.

I want to write a subroutine type_id which returns either 'int',
'double', 'text' (or '?') for each of the scalars, so that

print type_id($_), ' ' for (@L); print "\n";

results in the following output:

int text double text

I have found a solution where I use Devel::Peek, call Dump(), redirect
STDERR into an "in-memory" file ( \$data ) and analyse the "in-memory"
content:

$data =~ /^SV = IV(0x/ # for ints
$data =~ /^SV = NV(0x/ # for doubles
$data =~ /^SV = PV(0x/ # for text

but I wanted to know whether there is a better way.

**********************************************************
Here is my solution:

use strict;
use warnings;

use Devel::Peek;

print STDERR "Beginning of program\n";

my @L = (3, '3', 3.0, '3.0');

print type_id($_), ' ' for (@L);
print "\n";

print STDERR "End of program\n";

sub type_id {

  # ============================
  # At first I could not get the "in-memory"
  # working. It took me a while before I
  # found the all important documentation
  # in perldoc -f open:
  #
  # [...] if you try to re-open STDOUT or
  # STDERR as an "in memory" file, you have
  # to close it first [...]
  #
  # As a consequence, a simple
  #    local *STDERR;
  #    open STDERR, '>', \$data;
  # does not work.
  #
  # The following redirects STDERR into an
  # "in-memory" file, but leaves STDERR
  # closed on exit:
  #    local *STDERR = *STDERR;
  #    close STDERR;
  #    open STDERR, '>', \$data;
  #
  # so we have to dup STDERR first and
  # restore STDERR manually at the end
  # (...knowing that if the restore fails,
  # we won't have STDERR anymore):
  # ============================

    # dup STDERR
    open my $olderr, '>&', \*STDERR
      or return "?002 [dup STDERR: $!]";
    close STDERR
      or return "?005 [close STDERR: $!]";

    my $data = '';
    open STDERR, '>', \$data;
    Dump $_[0];
    close STDERR;

    # restore STDERR
    open STDERR, '>&', $olderr or die;

    if ($data =~ m{^SV = (.V)}) {
        if ($1 eq 'IV') { return 'int' }
        if ($1 eq 'NV') { return 'double' }
        if ($1 eq 'PV') { return 'text' }
        return "?020 [Invalid: SV = $1]";
    }
    return "?030 [Err: ".substr($data, 0, 12)."]";
}

--
Klaus



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

Date: 11 May 2007 07:10:06 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.7 $)
Message-Id: <464416cd$0$3582$ae4e5890@news.nationwide.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.7 $)
    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.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 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_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
        "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 <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



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

Date: 11 May 2007 00:18:34 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: warnings dilemma
Message-Id: <1178867914.687057.127600@q75g2000hsh.googlegroups.com>

On 10 May, 22:05, kj <s...@987jk.com.invalid> wrote:
> In <1178818888.039832.23...@y5g2000hsa.googlegroups.com> Brian McCauley <nobul...@gmail.com> writes:
>
>
>
> >On May 10, 5:28 pm, kj <s...@987jk.com.invalid> wrote:
> >> I've read the PODs (warnings, perllexwarn) but I still don't know
> >> how to solve this problem.  Here's a toy version of it.
>
> >> First some random module:
>
> >>   # Foo.pm
> >>   package Foo;
> >>   use strict;
> >>   use warnings;
>
> >>   # calling foo() will result in an 'uninitialized' warning
> >>   sub foo { my %h; exists $h{ $_[ 0 ] } }
> >>   1;
>
> >>   __END__
>
> >> The function Foo::foo represents one of those situtations in which
> >> the author of the module, for whatever reason, has not taken steps
> >> to avoid a default warning.
> >So you don't like something about the way the module works.
>
> No, that's *not* the problem.  The problem is that, as far as I
> can tell, there is no good way (either through code or through
> coding practices) to provide control over warnings to the calling
> script.  Every alternative is deficient in one way or another.

Well, yes that's true. Nothing's perfect.

> >> Next, my script
>
> >>   use strict;
> >>   use Foo;
> >>   { no warnings; Foo::foo(); }
> >>   exit;
>
> >> Now, despite the "no warnings" in the script, when I run it I still
> >> get the "Use of initialized value in exists" warning.
> >That's right. That's the whole point of lexical scope.
>
> I disagree.  I think a far more useful implementation of lexical
> control is to give each lexical scope the ability to control which
> warnings it allows to "bubble up" through it, in a way entirely
> analogous to the lexical control of fatal errors with eval.

The scope of control of fatal errors with eval() is _not_ lexical.
"Lexically scoped" describes the way "use warnings" or "use strict"
works now. What you want is the opposite of lexical scope - "dynamic
scope". This is what we had before we had lexical control with
local($^W) and what we still have with local($SIG{__WARN__}).

>  E.g.
> under this version, code like this:
>
>   if ( $verbose ) {
>     use warnings;
>     Foo::foo();
>   }
>   else {
>     no warnings;
>     Foo::foo();
>   }
>
> would result in warnings only if $verbose is true.  This is more
> useful than what we have now,

No it isn't. I'm not saying that the functionality you want would not
be useful sometimes but it would be usefull less often than what we
have now. I want to be able to suppress or promote warnings
selectively in _my_ code without an action-at-a-distance on other code
I happen to be calling.

> because it privileges scopes in
> proportion to their proximity to the top-level scope, as it should
> be.

I disagree. The descision as to which warning-causing circumstances
are expected and which are not (and which should be errors) belongs as
close as possible to where the expectation applies.

>  I don't understand why it wasn't designed like this in the
> first place...

Because the designers agree with my way of thinking.

With perl 5.10's new caller() you could write a lexically scoped
pragma that actually had dynamically scoped effect because you have
access to all the lexical scope hints in all calling stack frames.
However the bit that's responsible for determining what warning
categories are enabled is not AFAIK replacable so you couldn't make
this selective by category. As I said before that probably doesn't
matter because for what you are trying to do filtering by category
does not make much sense anyhow.



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

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


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