I've had to do something like this awhile back so here's
my baby perl version. Have fun!
#!/usr/bin/perl-w
use win32;
use strict;
# uncomment this out if you want to input the amount of chars
#if($#ARGV < 0) {
# die "usage: program.pl <padding chars> \n"
# . "for example: program.pl 30\n"
#}
#my $padlength = $ARGV[0];
my $in_name=$ARGV[0];
open(FILE,"numbers.txt") || die "numbers.pl can't open file: $!";
open(OUTPUT,">numberdump.txt") or die "numbers.pl can't open file: $!"
+;
while (<FILE>) {
chomp;
# sample input:
# UserID Date
# 423Hm54 ATHENA02 10/1/2000
# 123456Dh60 ATHENA02 10/1/2000
# 18Dh60 ATHENA02 10/2/2000
# 10Jch6 ATHENA05 10/2/2000
# 54321Hh24 ATHENA05 10/2/2000
# 21Mwm22 ATHENA03 10/2/2000
#Look only at the summary lines where $_ == 2000
next unless ($_ =~ /2000/i);
# this is to clean up the first variable length field
my $padchar = "0";
my $count = length($_);
my $padlength = 30; # comment this out if using ARGV
$padchar = $padchar x ($padlength-$count);
print $padchar, $_, "\n";
print OUTPUT $padchar, $_,"\n";
}
close FILE;
close OUTPUT;
# sample output:
# 000423Hm54 ATHENA02 10/1/2000
# 123456Dh60 ATHENA02 10/1/2000
# 000018Dh60 ATHENA02 10/2/2000
# 000010Jch6 ATHENA05 10/2/2000
# 054321Hh24 ATHENA05 10/2/2000
# 00021Mwm22 ATHENA03 10/2/2000
|