Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2015 15:44
Show Gist options
  • Save anonymous/2ebb0441bcdec4a94e48 to your computer and use it in GitHub Desktop.
Save anonymous/2ebb0441bcdec4a94e48 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
# NOTE This assumes the space aren't tabs and the columns are aligned
my $input = '
SCGR SC DEV DEV1 NUMDEV DCP STATE REASON
1 0 31 1
SCGR SC DEV DEV1 NUMDEV DCP STATE REASON
2 0 31 1
';
my @input_lines = split /\n/, $input;
foreach my $line (@input_lines) {
next unless $line;
my $dev = substr($line, 10, 15);
$dev =~ s/\s*//g;
unless ($dev) {
$line =~ s/(..........)(.....)/$1UNDEF/;
}
print $line."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment