I have a script that extracts data. I want the data that it extracts to be printed on the same line. I can't seem to make it work. It extracts the data but prints each find on a new line. The data that is being extracted also has to be delimited by a semi-colon. Here is the script.
And here is the out put I get.
Operator HSCSUNP1
;2004-01-09;
Code:
#!/usr/local/bin/perl -w
use Date::Manip;
$date=&ParseDate("Fri Jan 9");
$date=~ s/^(.{4})(.{2})(.{2})..:..:..$/$1-$2-$3/;
$file = "/u01/home/siswjh/logfile";
chdir("/u01/home/siswjh/appworx")|| die "can't cd to appworx :!";
opendir(APPWORX, "/u01/home/siswjh/appworx") or die "can't open directory :!";
foreach $name (readdir (APPWORX)){
next unless -f $name;
chomp $name;
open(FILE, "$name") || die "can't open $name for reading: $!";
open(OUT, ">>$file") || die "can't open $file for writing: $!";
while (<FILE>) {
if (/HSCSUNP1/) {
print OUT "$_;$date;";
#print OUT $date;
}
}
}
Operator HSCSUNP1
;2004-01-09;