Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Insert comma after every character

by johngg (Canon)
on Apr 21, 2010 at 14:01 UTC ( [id://836065]=note: print w/replies, xml ) Need Help??


in reply to Insert comma after every character

Yet another way would be to use substr working back from the right end of the string.

knoppix@Microknoppix:~$ perl -E ' > $str = q{ABCDEFG}; > substr $str, $_, 0, q{,} for reverse 1 .. length( $str ) - 1; > say $str;' A,B,C,D,E,F,G knoppix@Microknoppix:~$

I hope this is useful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found