punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
Memographic Monks,
Time flies like an arrow. Fruit flies like a banana.
I have
outputs@my_list = (3, 5, 2, 9); for $i (0 ..$#my_list) { print $my_list[$i]."|"; }
If I change the print to3529
it outputsprint $my_list[$i]."XX";
If I change it to3XX5XX2XX9XX
it outputsprint $my_list[$i]."|n";
But it will not output3|n5|n2|n9|n
as I want. Not even if I try3|5|2|9|
print $my_list[$i]."\|";
I know, pipe, perl control character....what's the trick to get it to print what I want?
Thanks.
UPDATE
Aie - holiday Monday programming - ok, time to take my lumps -
the code I provided was a short form for the real code which was
where more scanning the code revealed this helpful little line@my_list = (3, 5, 2, 9); for $i (0 ..$#my_list) { ... a bunch of stuff... $my_id_list .= $my_list[$i]."|"; ... a bunch more stuff... } print $my_id_list;
in ...a bunch more stuff..., which of course was the wrong place for it. Should'a been after the lop and before the print.#trim trailing delimiter $my_id_list =~ s/\|$//;
So, lessons #3,673,592 & #3,673,593: don't code half asleep on a holiday Monday; post real code or at least a sanitized version of it, not shortcuts.
Let the flagellation begin.
Time flies like an arrow. Fruit flies like a banana.
Back to
Seekers of Perl Wisdom