Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: process array with while loop

by ww (Archbishop)
on Nov 09, 2006 at 17:14 UTC ( [id://583160]=note: print w/replies, xml ) Need Help??


in reply to process array with while loop

But, as written (eg, with commas), it works

...so if it's not "THE (emphasis supplied, though absent from the original) accepted way" it might be less-preferred, but NOT UN-useable, so long as you know what you're you're doing (why and on what sort of data).

TIMTOWTDI

updated with more qualifications after ikegami slapt me upside the head re the commas (D'oh on me) and
<STRUCK> the boneheaded misstatement above after checking perlop which VERY SPECIFICALLY says,
A common mistake is to try to separate the words with comma or to put comments into a multi-line qw-string. For this reason, the use warnings pragma and the -w switch (that is, the $^W variable) produces warnings if the STRING contains the "," or the "#" character.

This ain't my day YAUpdate: ikegami points out that "Because of the spaces after the commas, the array does have multiple elements."

and just for the record, reason2006 's clarification below is noted without further dumb-ness from /me

The language in perlop also points out - or so it now seems to me - that OP's example is NOT "using a while loop and the diamond operator to process arrays" but is rather processing a one element array containing a list or string and relying on an unreliable behavior. Does this reading comport with the wisdom of the Monks? (cf my ref to ikegami above)

So far, about the only reliable part of this node is the first line and the quote from perlop...

AAAAArgh!

Replies are listed 'Best First'.
Re^2: process array with while loop
by reason2006 (Novice) on Nov 09, 2006 at 18:19 UTC
    Thanks for the correction, however, I free-typed the code in the original posting and errored in adding the commas to the qw() function strings. In my actual code, the while loop I gave an example of, works without the commas or when an array is created using a normal comma separated list.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-25 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found