H
havel.zhang
hi everyone:
Today I came cross a strange problem about function returning
point.
I have a function for replace chinses character to english character.
sub replace_par{
my $str = shift;
$str =~ s/\xA3\xA8/\(/;
$str =~ s/\xA3\xA9/\)/;
return $str;
}
Then I calling this function in a subroutine. as follows:
.... ...
### first we open a text file, and read line by line:
open(F,"<aaa.txt");
while(<F>){
.... ...
#according the context we have read, we named function name.
my $progName = $conf->{'feedname'} . '_slicecheck';
#calling the named function
my ($ret,$outline) = &$progName($conf,$data,$store);
if ($ret == 2){
... ...
};
print OUTPUT "$outline\n" if ($ret==0);
}
close(F);
close(OUTPUT);
exit(0);
#the calling function name is p4sup:
#
sub p4sup_slicecheck{
my $conf = shift;
my $data = shift;
my $store = shift;
#calling function replace_par,replace the chinese character
$data->{'english_name'} = replace_par($data->{'english_name'}) if
$data->{'english_name'} =~ /\xA3\xA8/
$l = length($data->{'english_name'});
$data->{'english_name'} .= ' ' x (100 - $l) if ($l < 100);
.... ...
}
then, after calling function replace_par, system should return to
subroutine4sup_slicecheck. But the system return to "close(OUTPUT)"
where the line before exit(0) !
Anyone hit this situation?
Thank u in advanced.
Havel Zhang
Today I came cross a strange problem about function returning
point.
I have a function for replace chinses character to english character.
sub replace_par{
my $str = shift;
$str =~ s/\xA3\xA8/\(/;
$str =~ s/\xA3\xA9/\)/;
return $str;
}
Then I calling this function in a subroutine. as follows:
.... ...
### first we open a text file, and read line by line:
open(F,"<aaa.txt");
while(<F>){
.... ...
#according the context we have read, we named function name.
my $progName = $conf->{'feedname'} . '_slicecheck';
#calling the named function
my ($ret,$outline) = &$progName($conf,$data,$store);
if ($ret == 2){
... ...
};
print OUTPUT "$outline\n" if ($ret==0);
}
close(F);
close(OUTPUT);
exit(0);
#the calling function name is p4sup:
#
sub p4sup_slicecheck{
my $conf = shift;
my $data = shift;
my $store = shift;
#calling function replace_par,replace the chinese character
$data->{'english_name'} = replace_par($data->{'english_name'}) if
$data->{'english_name'} =~ /\xA3\xA8/
$l = length($data->{'english_name'});
$data->{'english_name'} .= ' ' x (100 - $l) if ($l < 100);
.... ...
}
then, after calling function replace_par, system should return to
subroutine4sup_slicecheck. But the system return to "close(OUTPUT)"
where the line before exit(0) !
Anyone hit this situation?
Thank u in advanced.
Havel Zhang