Useless use of array element in void context

M

Michele Dondi

if (@old_line_num_to_comp == @out_line_num_to_comp) { ... }

But apparently here is the same problem, the comma operator is working
silently over the two arrays. This is tricky and I am wondering, why

No comma operator. Something different happening there; it checks
whether @old_line_num_to_comp and @out_line_num_to_comp have the same
number of elements.
Larry Wall or somebody else from you gurus is not inventing an
operator, just to compare two arrays, one element after the other :)

Well surprising as it may be, it turns out that "this kinda things" is
not required that often. And in *many cases*, but by all means *not*
in all of them, a simple

if ("@old_line_num_to_comp" eq "@out_line_num_to_comp") { ... }

would do it.


Michele
 
M

Michele Dondi

Thank you Peter!

Very polite of you to thank, but please quote *some* relevant context
from the posts you reply to, and put your comments below those
portions: this is considered good practice and greately aids
communication. You'll notice that most of us do, here.
of course! Little question to you more: you suggested:

my $same = 1;
$same = $same && $old_line[$_] == $out_line[$_] for (2 .. 6);
if ($same) { ... }

I changed to:

my $same = 1;
$same = $old_line[$_] == $out_line[$_] for (2 .. 6);
if ($same) { ... }

because I did not understand the use of the second "$same" after "="
Is it really needed?

You're confused by the absence of parentheses. Ask perl:

: gin:~ [14:35:40]$ perl -MO=Deparse,-p -e '$same = $same && $old_line[$_] == $out_line[$_] for (2 .. 6)'
: ;
: ($same = ($same && ($old_line[$_] == $out_line[$_]))) foreach (2 .. 6);
: -e syntax OK

You were probably thinking along the lines of

($same = $same) && ($old_line[$_] == $out_line[$_]))


Michele
 
D

Dr.Ruud

Michele Dondi schreef:
And "enfin" for us poor (Italian and most) English speaker is... "the
end"?

It can mean many things, depending how (tone and melody) it is said (or
written :).

at last, at the end, shortly, summarizing, oh well, still, &c &c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top