Skip to content

Instantly share code, notes, and snippets.

@JustinMcNamara74
Last active August 29, 2015 14:13
Show Gist options
  • Save JustinMcNamara74/4c872b7b9a9eb9902486 to your computer and use it in GitHub Desktop.
Save JustinMcNamara74/4c872b7b9a9eb9902486 to your computer and use it in GitHub Desktop.
#PERL Counts each "|" denoting a new column, and outputs the first 10 columns per line.
#!/usr/bin/env perl
while (my $row = <>) {
chomp $row;
my $num_of_pipes = $row =~ tr/|//;
while (($num_of_pipes < 10) && ($num_of_pipes > 0)) {
my $next_line = <>;
$row .= $next_line;
$num_of_pipes = $row =~ tr/|//;
}
print $row."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment