Hi,
I've run into following problem.
I need to process a list, and print every 5 errorcodes in one row and all errorcodes separated by a |. This is the list.
Thats the code I got so far.
Result running the code.
101222333444555666777888999000123234567890987342478
That's, how the result should look like.
101|222|333|444|555
666|777|888|999|000
123|234|567|890|987
342|478
Any help very much appreciated.
Dietmar
I've run into following problem.
I need to process a list, and print every 5 errorcodes in one row and all errorcodes separated by a |. This is the list.
Code:
##############
#errorcode.lst
##############
errorcode=101
errorcode=222
errorcode=333
errorcode=444
errorcode=555
errorcode=666
errorcode=777
errorcode=888
errorcode=999
errorcode=000
errorcode=123
errorcode=234
errorcode=567
errorcode=890
errorcode=987
errorcode=342
errorcode=478
Thats the code I got so far.
Code:
#!/usr/bin/perl -w
use strict;
my $LOGFILE = "d:/logfile.txt";
#Get all errorcodes from errcode.lst and put them into an array
sub get_errcode {
my $fh;
my @errfile;
my $ERRFILE = "d:/errorcode.lst";
my @errorcode;
open($fh, "<$ERRFILE") || &write_logfile($LOGFILE,"cannot read $ERRFILE");
@errfile=<$fh>;
close $fh;
foreach my $line (@errfile) {
next if ($line =~ /^#/);
chomp $line;
my($dummy, $errorcode) = split(/=/, $line);
push(@errorcode, $errorcode);
}
print @errorcode;
}
# Write Logfile
sub write_logfile {
my $message;
($LOGFILE,$message)=@_;
open(LOG, ">> $LOGFILE") || die "can't open or append file $LOGFILE: $!";
print LOG "$message";
close LOG;
}
get_errcode();
101222333444555666777888999000123234567890987342478
That's, how the result should look like.
101|222|333|444|555
666|777|888|999|000
123|234|567|890|987
342|478
Any help very much appreciated.
Dietmar