[Omaha.pm] Add a pipe to a pipe delim file

Jay Hannah jay at jays.net
Mon Dec 19 16:34:22 PST 2005


Problem:

You have a pipe delimited file and need to pretend that there's an extra field right after the 9th field.

Solution:

$ cat j.pl
#!/usr/bin/perl

while (<>) {
  my @l = split /\|/;
  $l[8] = "$l[8]|";
  print join "|", @l;
}

I ran it like so:

$ perl j.pl reward_event_ar.unl > reward_event_ar.unl.2

I'm sure there's a shorter solution out there, but that's how I code that solution off the top of my head.

j



More information about the Omaha-pm mailing list