Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

quick one

Posted on 2009-07-09
4
290 Views
Last Modified: 2012-05-07
I have a file with a sequence of hex numbers, one per line. I need to get them all on one line, comma delimited. I can get the comma on the end, but how do I join up all my little scalars into an array and print?

So far I have  perl -wnl -e 's/$/,/g;print' my-devs which gives me

0001,
0002,
etc...

I want 0001,0002

thanks.
0
Comment
Question by:Rowley
4 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24813711
Try this?

perl -wnl -e 's/[\n\r]+/,/gm;print'
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 125 total points
ID: 24814102
On windows, replace single quote ' with double quote "

#If you already have the comma's, and just need to join the lines:
perl -pe 'chomp' file.txt
 
#If you need to add comma's and join the lines:
perl -pe 's/[\r\n]+/,/' file.txt

Open in new window

0
 
LVL 13

Author Closing Comment

by:Rowley
ID: 31601591
spot on ta. -p - handy too. Other poster - sorry, didn't work.
0
 
LVL 84

Expert Comment

by:ozo
ID: 24814466
perl -wpl -e '$\=!s/$/,/;' my-devs
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question