$mydata =~ s/([\w\s]+)\s([\w\d]+)\s(0000.*)/$1,$2,$3/g; $mydata =~ s/(:\d{2})\s0000/$1,$2/g; #### #!/usr/bin/perl # NODE34853.pl # Assumptions: There are potentially any number of parts of a user's name. # For example, "Bill Clinton" might be a user's name, but # "William Jefferson Clinton the Liar" might also be his name. # The user's name is next, which is always one word long. Might also have numbers # in it, such as Bill69. # The data is currently in a single scalar (as though you read it from a flat file). # And, It's not clear what granularity you want the data to have. I'm assuming # that you want the user's name, his username, and the individual chunks of login # data. Do you also want to split up the login data? Your post didn't say. # # Knowing what you want to do with this data afterwards would also help. If you want to # load this into a SQL database, then you'd probably want to do this a bit differently. # But, if your goal is just to comma-delimit the file so you can load it into # a spreadsheet, then this oughta do the trick. # # This solution is really just a two line program with lots of comments and some # stuff to setup the environment and print the results. # I hope it helps. # --Mark # # This line just sets up the scalar variable you want to parse. # I'm assuming you have other methods of doing this (reading from # CSV, etc.) $mydata = <