>
> Well, the problem with perlform is: it expects a certain number of column.
>
> My question to you is: is the number of cell type constant or is it
> indeterminate?
>
> If it's indeterminate then it's better to stick with print, or printf
> if you want some formatting.
Cell is indeterminate. Always different.
Is it possible to create a header subroutine and call it when I create
the format?
I am getting the following error:
$ perl -c hehTest.pl
syntax error at hehTest.pl line 34, near "print format
header "
hehTest.pl had compilation errors.
.
What I have so far is below.
#!/usr/bin/perl
use warnings;
use strict;
use POSIX;
use Perl6::Form;
# my $filepath =
sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d%H",localtime));
my $filepath = ("/tmp/110923.APX"); # for testing
my $runTime =
sprintf("/home/cstinemetz/programs/%s.txt",strftime("%Y-%m-%d-%H:%M",localtime));
my $fileDate = strftime("%y%m%d%H%",localtime);
open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
open my $out, '>', $runTime or die "ERROR opening $runTime: $!";
sub header {
my $header = "CELL\t".join("\t",sort keys my %CELL_TYPE_COUNT)."\n";
return $_;
}
my %CELL;
my %CELL_TYPE_COUNT;
while (my $line = <DATA>) {
if ($line =~ /CELL\s+(\d+)\s+(.+?),.+?HEH/) {
$CELL{$1}{$2}++;
$CELL_TYPE_COUNT{$2}++;
}
}
print format
header => sub { return &header; }
# header
print "CELL\t".join("\t",sort keys %CELL_TYPE_COUNT)."\n";
# body
foreach my $cellNo (sort keys %CELL) {
print "$cellNo";
foreach my $info (sort keys %CELL_TYPE_COUNT) {
if (exists $CELL{$cellNo}{$info}) {
print "\t $CELL{$cellNo}{$info}";
}
else {
print "\t 0";
}
}
print "\n";
}
__DATA__
EPT:CELL 20 CDM 1, CRC, HEH
SUPPRESSED MSGS: 0
ERROR TYPE: ONEBTS MODULAR CELL ERROR
SET: DS1-MLG ASSOCIATION CHANGE
MLG 1 DS1 1,2
00 REPT:CELL 20 CDM 1, CRC, HEH
SUPPRESSED MSGS: 0
ERROR TYPE: ONEBTS MODULAR CELL ERROR
SET: DS1-MLG ASSOCIATION CHANGE
MLG 1 DS1 1,2
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/