We are migrating our contents from TS 6.1 AIX to TS 6.7.1 SP1 RH linux.The following code snippet doesn't work after the migration to linux. if($^O eq "MSWin32") { $selectedpath =~ s!^$iwmount\\default\\main\\.*\\WORKAREA\\[^\\]+\\!!; } else { $selectedpath =~ s!^$iwmount/default/main/.*/WORKAREA/[^/]+/!!; }Can someone tell me the reason for $selectedpath returning no value in linux:Thanks in advance.
Thanks Ghoti.The $selectedpath has no value
Here is the full section of code:# TS directoriesmy $iwhome = TeamSite::Config::iwgethome();my $iwmount = TeamSite::Config::iwgetmount();my $cgi = new CGI;# TS GUI parameters, for a complete list of available variables,# please refer to the TeamSite administration guidemy $area_path = $cgi->param("area_path");my $user_name = $cgi->param("user_name");my $user_role = $cgi->param("user_role");my $vpath = $cgi->param("vpath");# user selected files are stored as hashes in the @selectedhash arraymy $pcount=0;my $selectedpath;my @selectedhash;my $dcrParserObj;while($selectedpath = $cgi->param("path_$pcount")){ # strip out path in front of workarea vpath, so files are relative to workarea #if($^O eq "MSWin32") { $selectedpath =~ s!^$iwmount\\default\\main\\.*\\WORKAREA\\[^\\]+\\!!; } #else { $selectedpath =~ s!^$iwmount/default/main/.*/WORKAREA/[^/]+/!!; } my $selectedtype = $cgi->param("type_$pcount"); my $selectedname = $cgi->param("name_$pcount"); my $hash; $hash->{"type"} = $selectedtype; $hash->{"path"} = $selectedpath; push @selectedhash, $hash; $pcount++;}
That's classical infinite loop sample. Your thread never leaves while($selectedpath...) block.Sooner or later path_0, path_1, ... path_N List gets exausted and $selectedpath is undefined - for every subsequent $pcount value (till perhaps "Arithmetic Overflow" Error on the $pcount++; Command). Btw, unless I miss sometning here what does any of that have to do to "if" functionality?
I would think the issue is different - the path_# form variables are "old" form variables (5.x and earlier) - 6.x will not create those variables unless you are wrapping the call to your script through wdpro_menu.ipl.I suggest you implement a Show Env custom menu item (running show_env.ipl) and take a look - a lot has probably changed since this code was written.
The way it's coded it's an infinite loop regardless. In 6.x $selectedpath is then simply undefined from the very beginning - and the loop goes on.In 5.x it is undefined from oh say 7 - and looping goes on ad infinitum still
while($selectedpath = $cgi->param("path_$pcount")) { ... }
my @list = ("a", "b", undef, "c");while (my $x = shift(@list)) { print "X: $x\n";}print "DONE\n";
X: 'a'X: 'b'DONE
$selectedpath =~ s!^$iwmount/default/main/.*/WORKAREA/[^/]+/!!;
It is not an endless loop...
Ghoti is right. This code was initially written for TS 5.5.2. It works good on TS 6.1. But in 6.7.1 SP1 it breaks.