[32193] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3458 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 29 11:09:26 2011

Date: Fri, 29 Jul 2011 08:09: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           Fri, 29 Jul 2011     Volume: 11 Number: 3458

Today's topics:
    Re: =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_i (Heinrich Mislik)
        Does "prove" have a way of running pre-test initializat <news@lawshouse.org>
    Re: Does "prove" have a way of running pre-test initial <peter@makholm.net>
    Re: Does "prove" have a way of running pre-test initial <nospam.gravitalsun@hotmail.com.nospam>
    Re: Generating an anonymous reference to an OO method <rweikusat@mssgmbh.com>
    Re: Generating an anonymous reference to an OO method <tzz@lifelogs.com>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@seesig.invalid
        Search and replace question <laredotornado@zipmail.com>
    Re: Trouble running Perl script from within a Perl scri <cartercc@gmail.com>
    Re: why won't perl say which value was uninitialized? <rweikusat@mssgmbh.com>
        XML::Simple drives me mad <dvaldenaire@gmail.com>
    Re: XML::Simple drives me mad <RedGrittyBrick@spamweary.invalid>
    Re: XML::Simple drives me mad <nospam.gravitalsun@hotmail.com.nospam>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 29 Jul 2011 09:49:02 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_is_permission_?= =?UTF-8?Q?denied=E2=80=8F?=
Message-Id: <4e32820e$0$60386$3b214f66@usenet.univie.ac.at>

In article <d1854192-d66a-491a-89b6-c61e168ff877@m22g2000yqh.googlegroups.com>, j.joeyoung@gmail.com says...

Carefully read the error mesage:

> ld.so.1: perl: fatal: /export/home/oracle/oracle/product/
> 10.2.0/db_1/lib/libclntsh.so.10.1: Permission denied

Fhe file libclntsh.so.10.1 normally is owned by user oracle.
Check the permissions of the path and files in $ORACLE_HOME/lib

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: Thu, 28 Jul 2011 21:58:10 +0100
From: Henry Law <news@lawshouse.org>
Subject: Does "prove" have a way of running pre-test initialization?
Message-Id: <wsWdnXDRUu3tUKzTnZ2dnUVZ8vadnZ2d@giganews.com>

My test suite needs to have some directories initialised to a known 
state before the tests run.  There's a tar file which does it, but 
currently I'm manually deleting the old directories and extracting the 
tar file before running "prove -l".

Is there a standard way of getting "prove" to run a set of commands, or 
a program, before it runs?  I've googled for this but a suitable search 
string is hard: [perl prove initialize] and variants find nothing.

-- 

Henry Law            Manchester, England


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

Date: Fri, 29 Jul 2011 09:44:15 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Does "prove" have a way of running pre-test initialization?
Message-Id: <87y5zhtttc.fsf@vps1.hacking.dk>

Henry Law <news@lawshouse.org> writes:

> My test suite needs to have some directories initialised to a known
> state before the tests run.  There's a tar file which does it, but
> currently I'm manually deleting the old directories and extracting the
> tar file before running "prove -l".

Normally I just have the individual test scripts set up a well defined
test environment. Often I just include it directly in the scripts, but
other options is to put a module with common code i t/lib/MyTestCode.pm
or even to use Test:Class for the full setup/postcondition/teardown
framework.

//Makholm


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

Date: Fri, 29 Jul 2011 17:55:48 +0300
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: Does "prove" have a way of running pre-test initialization?
Message-Id: <j0uhl5$kh8$1@news.ntua.gr>

`rm -rf dir/*`
`tar  xf foo.tar -C dir` 




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

Date: Fri, 29 Jul 2011 11:55:54 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Generating an anonymous reference to an OO method
Message-Id: <87tya5cq4l.fsf@sapphire.mobileactivedefense.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:
>>>>>> "Matthew" == Matthew Pounsett <matt.pounsett@gmail.com> writes:
>
> Matthew> Is there a way to get an anonymous reference to an OO method
> Matthew> that can then be executed?
>
> Just create a closure:
>
>
>     my $maker = do {
>        my $class = "Digest::MD5"; # or however you want to determine this
>        sub { return $class->new->add(@_) };
>     };
>

Provided that $class never changes, an alternative with some possibly
desirable technical properties (such as not tying up the scalar $class
in order to determine a value which never changes during invocation)
would be (not actually compiled):

	eval("sub { return $class->new->add(".'@_); }');

This should create an anonymous subroutine which invokes the desired
operation without needing $class or its value when being called.

        


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

Date: Fri, 29 Jul 2011 07:17:34 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Generating an anonymous reference to an OO method
Message-Id: <878vrhb7s1.fsf@lifelogs.com>

On Fri, 29 Jul 2011 11:55:54 +0100 Rainer Weikusat <rweikusat@mssgmbh.com> wrote: 

RW> Provided that $class never changes, an alternative with some possibly
RW> desirable technical properties (such as not tying up the scalar $class
RW> in order to determine a value which never changes during invocation)
RW> would be (not actually compiled):

RW> 	eval("sub { return $class->new->add(".'@_); }');

RW> This should create an anonymous subroutine which invokes the desired
RW> operation without needing $class or its value when being called.

That is deeply nasty.  Why do you want to avoid a closure on $class?
The code is simpler with a closure, you don't have to create code
dynamically (so compile-time checks can work properly)...

Ted


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

Date: Fri, 29 Jul 2011 02:17:33 -0500
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <CoGdnRe5-94Qw6_TnZ2dnUVZ5gWdnZ2d@giganews.com>

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

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

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

    The article at:

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

    describes how to get answers from technical people in general.

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

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

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

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

    A note to newsgroup "regulars":

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

    A note about technical terms used here:

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

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

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

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

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

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

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

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

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

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

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

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

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

        One such searchable archive is:

         http://groups.google.com/advanced_search

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Fri, 29 Jul 2011 06:45:01 -0700 (PDT)
From: laredotornado <laredotornado@zipmail.com>
Subject: Search and replace question
Message-Id: <140cae34-8b05-40ac-9892-6c38a374d836@v7g2000vbk.googlegroups.com>

Hi,

I'm using Perl 5.10.6 on Mac 10.6.6.  I want to execute a simple
search and replace against a file ...

my $searchAndReplaceCmd = "perl -pi -e 's/\\Q${localTestDir}\\E//g' $
{testSuiteFile}";
system( $searchAndReplaceCmd );

but the problem above is the variable $localTestDir contains directory
separators, and this screws up the regular expression ...

Bareword found where operator expected at -e line 1, near "s/\Q/home/
selenium"
Backslash found where operator expected at -e line 1, near "Live\"
syntax error at -e line 1, near "s/\Q/home/selenium"
Search pattern not terminated at -e line 1.

How do I do a search and replace when the variable in questions
contains regular expression characters?  Thanks, - Dave


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

Date: Fri, 29 Jul 2011 06:44:57 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Trouble running Perl script from within a Perl script
Message-Id: <95bdf158-5d9a-4f22-9107-4709d207c0ae@z17g2000vbp.googlegroups.com>

On Jul 28, 11:52=A0am, "laredotorn...@zipmail.com"
<laredotorn...@gmail.com> wrote:
> I'm using Perl 5.10.1 on Ubuntu Linux 11.04. =A0I want to run a Perl
> script B from within Perl script A.

You might have some requirements that impose some other constraints on
your app, but if it were me, I would write Perl Script B as a module,
and 'use' it in Perl Script A. You can either call Perl Script A from
the command prompt, or create a cron job, but in either case, you can
call and execute your Perl Script B functions from Perl Script A just
as you could directly.

Besides which, if your Perl Script B functions were fundamental in
some sense, but creating a module you could reuse those functions in
script after script.

CC.


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

Date: Thu, 28 Jul 2011 21:33:35 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <877h72cfhc.fsf@sapphire.mobileactivedefense.com>

Keith Thompson <kst-u@mib.org> writes:
> Rainer Weikusat <rweikusat@mssgmbh.com> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>>> Rainer Weikusat <rweikusat@mssgmbh.com> writes:
>>>> Keith Thompson <kst-u@mib.org> writes:
>>>>> Rainer Weikusat <rweikusat@mssgmbh.com> writes:
>>>> [...]
>>>>
>>>>>>>> Why is this to be sacrificed on an altar dediciated to someone
>>>>>>>> who did a half-assed implementation of a warning for situation
>>>>>>>> which is perfectly legal because of a bad hangover and inbred
>>>>>>>> intolerance for differences, no matter if they happen to be
>>>>>>>> beneficial or not?
>>>>>>>
>>>>>>> Perfectly legal?  Then what should print do with an undef
>>>>>>> argument?
>>>>>>
>>>>>> Well, what it is supposed to do: Print nothing aka 'an empty
>>>>>> string'.
>>>>>
>>>>> What is the basis for your assertion that ``print undef'' is
>>>>> *supposed* to print an empty string?
>>>>
>>>> What is the basis for your assertion that the scalar representing
>>>> 'an undefined value' is supposed to behave differently from all
>>>> other Perl scalars wrt to stringification and conversion to a
>>>> numerical value, especially given that it doesn't?
>>>
>>> Oh, but it does; see below.
>>
>> It doesn't. Provided that someone unconditionally enables 'all runtime
>> warning which happen to exist' (in a suitable version of perl), a
>> 'uinitialized value ...' message is occasionally printed when an value
>> for which the defined-routine would return false is used.
>
> So you say it doesn't behave differently, and then you describe the
> circumstances in which it does behave differently.
>
> Or do you not consider the warning to be "behavior"?

Trivially, perl 'behaves differently' when runtime warnings are
enabled as opposed to when they are not enabled. However, that wasn't
what I was referring to and I think you should be aware of that.

>
>>>> 	Note that since "undef" is a valid scalar, its presence
>>>>         doesn't *necessarily* indicate an exceptional condition
>>>>
>>>> That's from the documentation of the 'defined' function.         
>>>
>>> Did you notice the word "necessarily" there?  It implies that the
>>> presence of "undef" sometimes *does* indicate an exceptional
>>> condition.
>>
>> Yes. As also documented in the same part of the perl documentation
>> (and at least once completely ignored by you in the past which makes
>> me think that you experience with Perl cannot possibly go back to the
>> time when definedness hadn't yet been invented[*]):
>
> I'm having trouble imagining any possible relevance for that last
> sentence.  Can you clarify?

Error in my part. I didn't remember anything about defined/ undef from
the time where I started using Perl, just that I learned about the
existence of both some years later. Consequently, I wrongly assumed
that they actually came into existence 'some years later'.

[...]

>>> If it didn't, the sentence would probably read:
>>>
>>> 	Note that since "undef" is a valid scalar, its presence doesn't
>>>       indicate an exceptional condition.
>>>
>>> But this:
>>>
>>>     print undef;
>>>
>>> does in fact trigger a warning (if warnings are enabled).
>>> So apparently an argument to print is one of the contexts where
>>> the presence of "undef" indicates an exceptional condition.
>>
>> Insofar you defined 'exceptional condition' as 'the interpreter prints
>> a useless message and performs the requested operation' (which might
>> or might not be the operation that should have been performed,
>> completely indepdentely of the useless message) then, an excpetional
>> condition has occurred whenever the useless message in question was
>> printed. But that's not how the text documenting the defined function
>> uses the term 'exceptional condition'.
>
> Please don't put words in my mouth.  Feel free to call the message
> "useless" if you like, but don't imply that I defined it that way.

?

[...]

>> I have absolutely no problems with the way perl 'treats undef'. OTOH,
>> you (and presumably, a lot of other people) have all kinds of
>> artificial technical problems because you desire to see something in
>> undef which it actually isn't.
>
> Just what technical problems do you think I have?

For instance, you would need to code technically redundant array
length or definedness checks in the case I originally used as an
example because 'numerical comparison' is not among the list of
'warning-free used of scalars with "undefined" values'.

[rw@splittermine]~/work/vmecs-logger $perl -we 'print $x > 0'
Name "main::x" used only once: possible typo at -e line 1.
Use of uninitialized value $x in numeric gt (>) at -e line 1.

BTW, the last time I looked, the Perl documentation referred to
'variables' as 'variables' and not as 'values' ...


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

Date: Fri, 29 Jul 2011 06:48:26 -0700 (PDT)
From: Denis Valdenaire <dvaldenaire@gmail.com>
Subject: XML::Simple drives me mad
Message-Id: <0757d9a2-e9b5-4c8f-8516-0be0decce504@p19g2000yqa.googlegroups.com>

Hello,

Here is my problem. I have a "data" in perl (I said a "data", because
i don't know WHAT it is. I know what it is not : not an ARRAY ref, not
an ARRAY, not a HASH ref, etc. etc. Every attempt i made to parse it
fails with an error message of that kind.), that was provider by
XML::Simple::XMLIn();

Let's consider the code :


#!/usr/bin/perl

use XML::Simple;
use Data::Dumper;

$xml = '<configuration>
        <sync_method type="common">
            <sync_modules>
                <ena name="was6"/>
                <ena name="wasconf"/>
                <dis name="ihs"/>
            </sync_modules>
	</sync_method></configuration>';


my $config = XMLin($xml, KeyAttr => "");

print Dumper($config->{sync_method}->{sync_modules}->{ena});

That gives me the following output (THE VERY "data") :

$VAR1 = [
          {
            'name' => 'was6'
          },
          {
            'name' => 'wasconf'
          }
        ];

My question : what i am supposed to do if i want to parse each name ?
like, processing was6 and then wasconf and then stop.

I believe I tried everything (keys, foreach, each, #{@->{%}}, etc...).
Do I do it the wrong way ?

Any suggestion is very welcome !


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

Date: Fri, 29 Jul 2011 15:19:05 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: XML::Simple drives me mad
Message-Id: <4e32c15b$0$2524$da0feed9@news.zen.co.uk>

On 29/07/2011 14:48, Denis Valdenaire wrote:
> $VAR1 = [
>            {
>              'name' =>  'was6'
>            },
>            {
>              'name' =>  'wasconf'
>            }
>          ];


#!/usr/bin/perl
use strict;
use warnings;

my $VAR1 = [
              {
               'name' => 'was6'
              },
              {
                'name' => 'wasconf'
              }
            ];


for my $row (@$VAR1) {
   print $row->{name}, "\n";
}


-- 
RGB


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

Date: Fri, 29 Jul 2011 17:35:25 +0300
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: XML::Simple drives me mad
Message-Id: <j0uges$fd2$1@news.ntua.gr>

# I think you want something like this



print $config->{sync_method}->{sync_modules}->{dis}->{name}  ,"\n";
print $config->{sync_method}->{sync_modules}->{ena}->[0]->{name} ,"\n";
print $config->{sync_method}->{sync_modules}->{ena}->[1]->{name} ,"\n";


print "\n\n\n-----------\n\n\n";


foreach my $k1 (keys $config->{sync_method}->{sync_modules})
{
my $k2 = $config->{sync_method}->{sync_modules}->{$k1};


 if ( 'ARRAY' eq ref $k2 )
 {
  foreach (@{$k2})
  {
  print "$k1 , $_->{'name'}\n";
  }
 }
 elsif ( 'HASH' eq ref $k2 )
 {
  foreach my $k3 (keys %{$k2})
  {
  print "$k3 $k2->{$k3}\n";
  }
 }
} 




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

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


------------------------------
End of Perl-Users Digest V11 Issue 3458
***************************************


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