|
From: nickli on 7 Nov 2006 09:53 Hi, I have a file with 100 lines each with one record on each line. The file is as follows: 86274886 81459795 78113464 87882848 78286396 77618550 84180945 74310227 69806585 74111006 80947497 80404769 80377684 80259589 68195927 67187136 67345008 78745575 77970192 77937896 85872999 85954776 85930231 85927774 85887197 85911310 85577810 85645926 85645257 85609385 85428783 85455622 86143491 86143435 85501684 86168358 86143964 86036286 85830781 86159082 98624907 98484232 98506935 21986088 103299004 101901712 21246519 69548444 69534265 98523400 51579566 63869631 47500761 63974605 63727180 48348160 51465556 51468035 50245797 49894334 90940723 16226272 16222857 16215465 16199374 16184704 16355800 16320328 54274394 54210417 79781445 79778999 79772052 79720217 79719727 80117560 80102759 80152647 80116881 79976145 19592974 19587585 19585909 19574981 19574860 19574560 19659755 19654534 19636650 19630077 17823273 17817739 17764284 17728035 17694825 17766363 17730554 17675729 17803920 17773924 I would like to put 5 records on a line, separated by commas, with a total of 20 lines: ,86274886,81459795,78113464,87882848,78286396 ,80947497,80404769,80377684,80259589,68195927 ...................................... ...................................... I can do this with shell script using split and paste commands. I would like to ask for help as I am new to Perl. Thanks in advance. Nick Li
From: John W. Krahn on 7 Nov 2006 10:10 nickli wrote: > > I have a file with 100 lines each with one record on each line. The > file is as follows: > > 86274886 > 81459795 > 78113464 [ snip ] > 17675729 > 17803920 > 17773924 > > I would like to put 5 records on a line, separated by commas, with > a total of 20 lines: > > ,86274886,81459795,78113464,87882848,78286396 > ,80947497,80404769,80377684,80259589,68195927 > ...................................... > ...................................... perl -lpe'$\=$.%5?",":$/' yourfile John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall
From: nickli on 8 Nov 2006 16:59 Thanks a lot! On Nov 7, 10:10 am, "John W. Krahn" <some...(a)example.com> wrote: > nickli wrote: > > > I have a file with 100 lines each with one record on each line. The > > file is as follows: > > > 86274886 > > 81459795 > > 78113464[ snip ] > > > 17675729 > > 17803920 > > 17773924 > > > I would like to put 5 records on a line, separated by commas, with > > a total of 20 lines: > > > ,86274886,81459795,78113464,87882848,78286396 > > ,80947497,80404769,80377684,80259589,68195927 > > ...................................... > > ......................................perl -lpe'$\=$.%5?",":$/' yourfile > > John > -- > Perl isn't a toolbox, but a small machine shop where you can special-order > certain sorts of tools at low cost and in short order. -- Larry Wall
From: John Bokma on 8 Nov 2006 17:07 "nickli" <ningli2000(a)hotmail.com> wrote: not for top posting... > Thanks a lot! -- John Experienced Perl programmer: http://castleamber.com/ Perl help, tutorials, and examples: http://johnbokma.com/perl/
|
Pages: 1 Prev: WIN32::OLE excel date Next: how to load 'formats' from a file |