Hi, All,

It is very strange. I have an Perl application developed on Unix box and
want to port to Windows environment. All my file handlers only read the
first line in the applications developed in Unix although they were working
fine in Unix environment. Any clue?

Thanks.

sub readTaskHelp {

my($fn,$rest) = @_;

# print "FN: $fn<br>\n";

open HLPF, "<$fn" or

&echoErrs(*STDOUT,"open:$fn",__FILE__,__LINE__,"$!");

# read content into a hash array %U

my($hlpf,$vfn,$t1,$t2,$tag,$i,$j,%U,$itms,$itm,$v,$var,@a);

$itm= ""; # item from $tt

$itms = ""; # a list of items

$i = ""; # next item

$j = 0; # count within an item

$v=$var=""; $t1=$t2="";

%U=();

while (<HLPF>) {

print "$_<br>\n";

next if ($_ =~ /^#/); # skip comment lines

if ($_ =~ /^\.(\w+)\s*(.*)/) {

if ($itm ne lc($1) && $t1) {

$U{$itm}[0][1]=$t1; # record item content

$t1 = "";

}

$itm = lc($1);

if ($itms) { $itms .= ",$itm"; } else { $itms=$itm; }

$j=0; $t1=$2; # reset counter and record content

$U{$itm}[0][0]=ucfirst($itm); next;

}

if ($_ =~ /^\~\s*(.*)/) { # append contents

$t1 .= " $1"; next;

}

if ($_ =~ /^\-\s*([\w ]*):(.*)/) { # "- Get Info:"

if ($v ne $1 && $t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ""; $v=$1;

}

$t2 = ""; ++$j; $var=$1; # reset content holder and counter

$U{$itm}[$j][0]=$1; $t2 = $2;

} elsif ($_ =~ /^-\s*(-\w)\s*(.*)/) { # "- -t "

if ($v ne $1 && $t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ""; $v=$1;

}

$t2 = ""; ++$j; $var=$1;

$U{$itm}[$j][0]=$1; $t2 = $2;

}

if ($_ =~ /^ \s*(.*)/) { # " " two blank spaces

$t2 .= " $1"; $v = $var; next;

}

if ($_ =~ /^\s*$/) {

if ($t1) {

$U{$itm}[0][1]=$t1; # record item content

$t1 = ""; $i=$itm;

}

if ($t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ""; $v=$var;

}

next;

}

}

close(HLPF);

$U{'items'}=$itms; $itms="";

return %U;

}






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to