(split/,/)[1..8,0] this splits $_ on the , and moves the first element to the 9 position.
ie. $_ = '111,222,333,444,555,666,777,888,999,000'; will now be returned as an array (222, 333, 444, 555, 666, 777, 888, 999, 111) notice: no matter how long the $_ is and how many , it has it only returns 9 elements where the first one is moved to the last place and the rest gone.. I think you can guess what: (split/\W/)[8,0..7] does now. as for sorting.. remember that for the sort() function any sorting subroutine (anonomous or referenced) must return -1, 0, or 1. It took some practice to get it down the first time, but after that I am now the Sort King in my office when it comes to Perl. > -----Original Message----- > From: Patrick Salmon [mailto:pat@;salmonfamily.org] > Sent: Monday, October 28, 2002 10:41 AM > To: [EMAIL PROTECTED] > Subject: Decoding code. > > > I've been working on sorting by IP Address in an output file > that comprises field1(hostname), field2(hosttype), IP Address. > [snip] > > print > map{sprintf(("%d.%d.%d.%d,"x2)."%s\n",(split/,/)[1..8,0])} # > Break the IP addresses into numeric strings. Do it 2 times. > # Is the '"%s\n"' identifying the final (text) field? Then > it'll 'split' the record on each delimiting comma. > sort > map{sprintf"%s".",%3d"x8,(split/\W/)[8,0..7]} > # Put it back together in the same field sequence? Don't > quite see how the "USA" entry is being put back into the string. > # Why 'split', and not 'join'? > <DATA> > 1.2.3.4,1.2.3.255,USA > 2.3.4.0,2.3.4.25,USA > > > What's really causing my head to ache is not fully > understanding what the [1..8,0] and [8,0..7] values are doing > and their effect upon the resulting string. Does the '8' > value reflect the total number of IP fields to be worked on? > What's happening with the final string of text? > [snip] ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]