Perl to create an empty line if fields are equal
I have a rather large pipe delimmited file and I would like to break it down into sections simply by putting an empty line if the second filed is different from the second field in the previous line.
For example if the file is: 1|4847|test|393|somthing I would like to have a new file which reads: 1|4847|test|393|somthingAny suggestions you have is greatly appreciated. |
if they are sequential maybe something like
Code:
while(<>) |
There are probably betters ways of doing it, but this is the first one I can think of.
Just feed the script with the data with a pipe, a redirection or give the filename as an argument. Code:
#!/usr/bin/perl Cheers! |
All times are GMT -5. The time now is 08:52 PM. |