Hi,
I am very very new to Perl. I inherited a program and I need to get rid of white spaces. I found a routine that will do it but when I try run it I get a syntax error. Here is the code:
#
# nbr_FormatProducerRecord.pl
#
# nbr_FormatRelateRecord.pl 6.30.98 jhb
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub FormatOverProdUseRecord
{
local (%overprodusefil, $appLog) = @_;
my ($TRUE) = 1;
my ($FALSE) = 0;
my ($rc) = $FALSE;
local (%log) = ("logProcess", "",
"logType", "",
"logText", "",
"logFile", "");
$log{logFile} = $appLog;
$log{logProcess} = "nbr_FormatOverProdUseRecord.pl";
my ($fileName) = $ENV{fullFileName};
unless(open (OVERPRODUSEFIL, ">>$fileName"))
{
&LogMsg ("E","Can\'t open file $fileName.");
return $FALSE;
}
unless (printf OVERPRODUSEFIL ("%-11s" . # tin
"%-3s" . # location_cd
"%-5s" . # use_ind
"%-3s" . # use_st
"%-11s" . # eff_dt
"%-11s" . # end_dt
"%-11s" . # created_dt
"%-9s" . # created_userid
"%-11s" . # last_updated_dt
"%-8s\n" , # last_updated_userid
trim($overprodusefil{tin}),
trim($overprodusefil{location_cd}),
trim($overprodusefil{use_ind}),
trim($overprodusefil{use_st}),
trim($overprodusefil{eff_dt}),
trim($overprodusefil{end_dt}),
trim($overprodusefil{created_dt}),
trim($overprodusefil{created_userid}),
trim($overprodusefil{last_updated_dt}),
trim($overprodusefil{last_updated_userid})
))
{
&LogMsg ("E","Can\'t write to file $fileName.");
return $FALSE;
}
unless (close(OVERPRODUSEFIL))
{
&LogMsg ("E","Can\'t close file $fileName.");
return $FALSE;
}
return $TRUE;
}
;
All I did was to insert the trim function. Could someone please help me find the syntax error.
Thanks
Mark
I am very very new to Perl. I inherited a program and I need to get rid of white spaces. I found a routine that will do it but when I try run it I get a syntax error. Here is the code:
#
# nbr_FormatProducerRecord.pl
#
# nbr_FormatRelateRecord.pl 6.30.98 jhb
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub FormatOverProdUseRecord
{
local (%overprodusefil, $appLog) = @_;
my ($TRUE) = 1;
my ($FALSE) = 0;
my ($rc) = $FALSE;
local (%log) = ("logProcess", "",
"logType", "",
"logText", "",
"logFile", "");
$log{logFile} = $appLog;
$log{logProcess} = "nbr_FormatOverProdUseRecord.pl";
my ($fileName) = $ENV{fullFileName};
unless(open (OVERPRODUSEFIL, ">>$fileName"))
{
&LogMsg ("E","Can\'t open file $fileName.");
return $FALSE;
}
unless (printf OVERPRODUSEFIL ("%-11s" . # tin
"%-3s" . # location_cd
"%-5s" . # use_ind
"%-3s" . # use_st
"%-11s" . # eff_dt
"%-11s" . # end_dt
"%-11s" . # created_dt
"%-9s" . # created_userid
"%-11s" . # last_updated_dt
"%-8s\n" , # last_updated_userid
trim($overprodusefil{tin}),
trim($overprodusefil{location_cd}),
trim($overprodusefil{use_ind}),
trim($overprodusefil{use_st}),
trim($overprodusefil{eff_dt}),
trim($overprodusefil{end_dt}),
trim($overprodusefil{created_dt}),
trim($overprodusefil{created_userid}),
trim($overprodusefil{last_updated_dt}),
trim($overprodusefil{last_updated_userid})
))
{
&LogMsg ("E","Can\'t write to file $fileName.");
return $FALSE;
}
unless (close(OVERPRODUSEFIL))
{
&LogMsg ("E","Can\'t close file $fileName.");
return $FALSE;
}
return $TRUE;
}
;
All I did was to insert the trim function. Could someone please help me find the syntax error.
Thanks
Mark