punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't / won't print pipe delimiter?
by Old_Gray_Bear (Bishop) on May 18, 2009 at 16:42 UTC | |
by Marshall (Canon) on May 18, 2009 at 21:39 UTC | |
by Anonymous Monk on May 18, 2009 at 16:51 UTC | |
|
Re: Can't / won't print pipe delimiter?
by talexb (Chancellor) on May 18, 2009 at 17:45 UTC | |
by punch_card_don (Curate) on May 18, 2009 at 18:39 UTC | |
by talexb (Chancellor) on May 18, 2009 at 21:04 UTC | |
|
Re: Can't / won't print pipe delimiter?
by BrowserUk (Patriarch) on May 18, 2009 at 16:40 UTC | |
|
Re: Can't / won't print pipe delimiter?
by Anonymous Monk on May 18, 2009 at 16:38 UTC | |
|
Re: Can't / won't print pipe delimiter?
by artist (Parson) on May 18, 2009 at 16:39 UTC | |
by chromatic (Archbishop) on May 18, 2009 at 21:14 UTC |