Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Reading & in Perl
cheeku
I have a text file in which on one line, I have "&".
When my DCR starts reading the text then it is giving error. I am using following code to read lines of text file
open (fhLineOfFile,"$strNameOfFile");
$strLineOfFile = <fhLineOfFile>;
Please tell me how I can read text file having this special character
Find more posts tagged with
Comments
Jeremy
I am not sure I understand what you mean by "When my DCR starts reading the text". Do you have a callout or something that gets the DCR to read in from a text file?
cheeku
Please refer to the following code
$strNameOfFile = "Y:/$strIwBranch/WORKAREA/adidas/sitemap/MyFile";
open (fhLineOfFile,"$strNameOfFile");
$strLineOfFile = <fhLineOfFile>;
In this my $strLineOfFile has & & due to this it is giving error
Jeremy
Maybe you should post a little more of the code and where it is being called. I just created a small perl script and a text file with an "&" in it and used your code and it read it fine.
Maybe you can post more of the script and the exact error you are receiving.
cheeku
$strNameOfFile = "Y:/$strIwBranch/WORKAREA/adidas/sitemap/MyFile";
open (fhLineOfFile,"$strNameOfFile");
$strLineOfFile = <fhLineOfFile>;
$strDCT=$strDCT."<container name=\"cntGroupHeading $iContainerCount\">
while ($strLineOfFile ne "" )
{
$strLineOfFile =~ s/^\s+//;
@acWordsOfLine
= split(/#/, $strLineOfFile);
$strDCT = $strDCT."<item name=\"txtLinkText $iContainerCount$iItemCount\" rowcontinue=\"t\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter Link Text</description><text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default>$acWordsOfLine[2]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtSubgroupHeading $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Sub-group Heading\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter this for logical grouping of links</description><text size = \"30\"></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkUrl $iContainerCount$iItemCount\" rowcontinue=\"f\" colspan=\"4\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link URL</description><text size = \"118\"><default>$acWordsOfLine[3]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkType $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link text</description><text><default>$acWordsOfLine[1]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"chkShowOnSiteMap $iContainerCount$iItemCount\"><label><![CDATA[<font class=\'adidascom_textfield\'>Show On SiteMap\ \ \ \ \ \ \ \ \ \ \ \ </font><br/><br/><br/>]]></label><description>Check to show link on sitemap otherwise not</description><checkbox><option value=\"check\" label=\"\" selected=\"t\"></option></checkbox></item>\n";
$strLineOfFile = <fhLineOfFile>;
$strLineOfFile =~ s/^\s+//;
$iItemCount++;
$strDCT = $strDCT."</container>\n";
$strLineOfFile = <fhLineOfFile>;
}
close fhLineOfFile;
This is the code I am Using to dynamically generate containers by reading the values from file.
It is working fine if my file has no "&" in any line, otherwise it is saying Internal server error.
Jeremy
Oh ok. I follow now. Now what if you used the "&" instead of a "&" in the text file? Is that feasible?
cheeku
That is fine, But I don't want to modify my text files as they are huge in number.
Couldn't I read & then replace the same for future use.
Adam Stoller
You seem to have some typos in the code you posted - e.g.:
$strDCT=$strDCT."<container name=\"cntGroupHeading $iContainerCount\">
";
It might also be nice to understand a bit of the underlying philosophy behind what you're trying to do such as why you expect to find '#'s within the various lines of text, and are you really trying to build a DCT from some other source?
There also appears to still be missing code (such as the declaration and initialization of
$iContainerCount
and
$iItemCount
).
You also will probably want to fix all those
 
's to be
 
;
's
The logic in the code seems a bit odd too - like the fact that you read from
fhLineOfFile
once before the loop and
twice
within the loop.
Not knowing exactly what you are trying to do - all I can suggest is a cleaner construct of the code:
my $strIwBranch = "something-goes-here";
my($iContainerCount, $iItemCount) = (0, 0);
my $strNameOfFile = "Y:/$strIwBranch/WORKAREA/adidas/sitemap/MyFile";
my $strDCT = '';
my $sp = ' ';
my
@data
;
if (open(IN, "<$strNameOfFile")){
@data
= <IN>;
close(IN);
}
foreach (
@data){
# $_ is what used to be $strLineOfFile
s/^\s+//;
my
@acWordsOfLine
= split(/\#/, $_);
$strDCT .= qq(<item name="txtLinkText $iContainerCount$iItemCount" rowcontinue="t">
<label><![CDATA[<font colass="adidascom_textfield">Link Text) .
$sp x 26 .
qq(</font>]]></label>
<description>Enter Link Text</description>
<text required="t" validation-regext="[^\\s]" size="30">
<default>$acWordsOfLine[2]</default>
</text>
</item>
<item name="txtSubgroupHeading $iContainerCount$iItemCount rowcontinue="f">
...
</item>
...
<item name="chkShowOnSiteMap $iContainerCount$iItemCount">
<lable><![CDATA[<font class="adidascom_textfield">Show On SiteMap) .
$sp x 12 .
qq(</font><br/><br/><br/>]]></label>
<description>Check to show link on sitemap otherwise not</description>
<checkbox><option value="check" label="" selected="t"></option></checkbox>
</item>\n);
shift
@data
;
# not sure why you want this?
$strDCT .= qq(<container>\n);
}
Hope that helps a little bit - but as I said - with a better understanding of what you are actually trying to do - the better chance you have of getting solutions to your problem - it's always possible that there is a flaw early on in the logic that makes the entire problem disappear when corrected rather than trying to fix code that's already in existance.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
cheeku
That was just a cut paste & editing mistakes by me on the complete code.The Exact code is below. Please see this code & then tell me if I could read "&" in this file from files.
my $iContainerCount = 1;
my $iArrayLength = 0;
my $iItemCount;
my $iNoOfFilesInDir;
my $strFiles;
my $strNameOfFile;
my $strLineOfFile;
my $strLineOfBannerFile;
my $strBannerFile;
my $strDCT;
my
@acFilesInDir
;
my
@acAllFilesInDir
;
my
@acWordsOfLine
;
my
@acBannerPath
;
$strDCT = "<substitution>\n";
################################################################################
################# Enviroment Variable to get branch and User ##################
################################################################################
my $strIwBranch;
my $strIwWorkarea;
my ( $strIwBranch, $strIwWorkarea ) = ($ENV{'IW_WORKAREA'} =~ /(.+)\/WORKAREA\/([^\/]+)/);
my
@acTemp
= split("/",$strIwBranch);
my $strCountry=
@acTemp[4]
;
my $strRootBranch=$acTemp[3];
################################################################################
#################To get user group by calling getUserGroup.ipl #################
################################################################################
my $strUser = $ENV{'IW_USER'};
my $strFilter = "";
my $iFlag;
$strFilter = `F:/iw-home/iw-perl/bin/iwperl.exe Y:/default/main/$strRootBranch/WORKAREA/global/common_dcts/getUserGroup.ipl $strUser`;
$iFlag = $strFilter =~ /GEM/;
$iFlag = $strFilter =~ /IT/;
my $strImagePath="";
my $strMoviePath="";
### To set path for Browse button of images and banners dynamically according to the User group
if ($iFlag == 0)
{
$strImagePath=$strCountry."/WORKAREA/adidas/images";
}
else
{
$strImagePath="WORKAREA/global/images";
}
################################################################################
##################Code to read all files present in directory ##################
################################################################################
opendir( fhMyDir,"Y:/$strIwBranch/WORKAREA/adidas/sitemap/" );
@acAllFilesInDir
= readdir(fhMyDir);
foreach $files(
@acAllFilesInDir
)
{
$strFiles=$files;
if(!($strFiles =~ /\bzz_tst/))
{
@acFilesInDir[$iArrayLength]=$strFiles
;
$iArrayLength++;
if($files ne "." && $files ne ".." )
{
$iNoOfFilesInDir++;
}
}
}
################################################################################
## Prepare the final string to be passed to the DCT
################################################################################
$strDCT=$strDCT.
"
<container name=\"cntBrowserTitle\" combination=\"and\" >
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>Browser Title</td></tr></table>]]></label>
<item name=\"txtBrowserTitle\">
<description>Enter Browser Title</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Browser Title\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default>adidas-Site map</default></text>
</item>
</container>
<container name=\"cntSitemapTitle\" combination=\"and\" >
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>Sitemap Title</td></tr></table>]]></label>
<item name=\"txtSitemapTitle\">
<description>Enter Site map Title</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Sitemap Title\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default>Site map</default></text>
</item>
</container>
";
################################################################################
############# Dynamic genaration of page containers and its content#############
################################################################################
for( $iContainerCount = 1; $iContainerCount <= $iNoOfFilesInDir; $iContainerCount++ )
{
$strNameOfFile = "Y:/$strIwBranch/WORKAREA/adidas/sitemap/".$acFilesInDir[$iContainerCount+1];
open (fhLineOfFile,"$strNameOfFile");
$strLineOfFile = <fhLineOfFile>;
$strDCT=$strDCT."<container name=\"cntGroupHeading $iContainerCount\">
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>$acFilesInDir[$iContainerCount+1] Page</td></tr></table>]]></label>\n";
$strDCT=$strDCT."<item name=\"txtPageName\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Page Title\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Page Title</description><text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\" ><default>$acFilesInDir[$iContainerCount+1]</default></text></item>\n";
$strDCT=$strDCT."<item name=\"txtPageUrl\" colspan=\"6\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Page URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Page URL</description><text required=\"t\" validation-regex=\"[^\\s]\" size = \"118\" ><default></default></text></item>\n";
$iItemCount=1;
while ($strLineOfFile ne "" )
{
if(!($strLineOfFile =~ /\bBanner/))
{
$strLineOfFile =~ s/^\s+//;
@acWordsOfLine
= split(/#/, $strLineOfFile);
$strDCT = $strDCT."<item name=\"txtLinkText $iContainerCount$iItemCount\" rowcontinue=\"t\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter Link Text</description><text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default>$acWordsOfLine[2]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtSubgroupHeading $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Sub-group Heading\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter this for logical grouping of links</description><text size = \"30\"></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkUrl $iContainerCount$iItemCount\" rowcontinue=\"f\" colspan=\"4\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link URL</description><text size = \"118\"><default>$acWordsOfLine[3]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkType $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link text</description><text><default>$acWordsOfLine[1]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"chkShowOnSiteMap $iContainerCount$iItemCount\"><label><![CDATA[<font class=\'adidascom_textfield\'>Show On SiteMap\ \ \ \ \ \ \ \ \ \ \ \ </font><br/><br/><br/>]]></label><description>Check to show link on sitemap otherwise not</description><checkbox><option value=\"check\" label=\"\" selected=\"t\"></option></checkbox></item>\n";
}
if($strLineOfFile =~ /\bBanner/)
{
@acBannerPath
= split('/',$strLineOfFile);
@acBannerPath
= reverse(
@acBannerPath
);
$BannerName = $acBannerPath[0];
$strBannerFile = "Y:/$strIwBranch/WORKAREA/adidas/bannerlib/banner";
open (fhLineOfBannerFile,"$strBannerFile");
$strLineOfBannerFile = <fhLineOfBannerFile>;
while($strLineOfBannerFile ne "" )
{
if($strLineOfBannerFile =~ /$BannerName/)
{
$strLineOfBannerFile =~ s/^\s+//;
$strLineOfBannerFile = <fhLineOfBannerFile>;
@acWordsOfLine
= split(/#/, $strLineOfBannerFile);
$strDCT = $strDCT."<item name=\"txtLinkText $iContainerCount$iItemCount\" rowcontinue=\"t\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter Link Text</description><text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default>$acWordsOfLine[2]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtSubgroupHeading $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Sub-group Heading\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter this for logical grouping of links</description><text size = \"30\"></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkUrl $iContainerCount$iItemCount\" rowcontinue=\"f\" colspan=\"4\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link URL</description><text size = \"118\"><default>$acWordsOfLine[3]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"txtLinkType $iContainerCount$iItemCount\" rowcontinue=\"f\"><label><![CDATA[<font class=\'adidascom_textfield\'>Link Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label><description>Enter the link text</description><text><default>$acWordsOfLine[1]</default></text></item>\n";
$strDCT = $strDCT."<item name=\"chkShowOnSiteMap $iContainerCount$iItemCount\"><label><![CDATA[<font class=\'adidascom_textfield\'>Show On SiteMap\ \ \ \ \ \ \ \ \ \ \ \ </font><br/><br/><br/>]]></label><description>Check to show link on sitemap otherwise not</description><checkbox><option value=\"check\" label=\"\" selected=\"t\"></option></checkbox></item>\n";
}
$strLineOfBannerFile = <fhLineOfBannerFile>;
$strLineOfBannerFile =~ s/^\s+//;
}
close fhLineOfBannerFile;
}
$strLineOfFile = <fhLineOfFile>;
$strLineOfFile =~ s/^\s+//;
$iItemCount++;
}
$strDCT = $strDCT."</container>\n";
}
close fhLineOfFile;
if($iFlag==0)
{
$strDCT = $strDCT.
"<container name=\"cntImages\">
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>Brand Images</td></tr></table>]]></label>
<item name=\"txtBrandText\">
<description>Enter Brand Text</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Brand text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<readonly>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\" ><default></default></text>
</readonly>
</item>
<item name=\"repBrandImages\" value=\"repBrandImages\">
<label>Brand Images</label>
<replicant min=\"1\" max=\"4\" combination=\"and\">
<item name=\"txBrandImage\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Brand Image\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Brand Image of size 47*46</description>
<readonly>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"98\">
### Calling filebrowser.cgi, to select image from the windows browser
<cgi-callout url=\"/iw-bin/$strRootBranch/filebrowser.cgi/$strRootBranch/".$strImagePath."__I*47*46\" label=\"Choose Image\" window-features = \"width=800,height=500,resizable=yes,toolbar=no,scrollbars=yes\"/>
</text>
</readonly>
</item>
<item name=\"txtLinkURL\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Link URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Link URL</description>
<readonly>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"118\"><default></default></text>
</readonly>
</item>
</replicant>
</item>
</container>";
}
else
{
$strDCT = $strDCT.
"<container name=\"cntImages\">
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>Brand Images</td></tr></table>]]></label>
<item name=\"txtBrandText\">
<description>Enter Brand Text</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Brand text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\" ><default></default></text>
</item>
<item name=\"repBrandImages\" value=\"repBrandImages\">
<label>Brand Images</label>
<replicant min=\"1\" max=\"4\" combination=\"and\">
<item name=\"txBrandImage\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Brand Image\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Brand Image of size 47*46</description>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"98\">
### Calling filebrowser.cgi, to select image from the windows browser
<cgi-callout url=\"/iw-bin/$strRootBranch/filebrowser.cgi/$strRootBranch/".$strImagePath."__I*47*46\" label=\"Choose Image\" window-features = \"width=800,height=500,resizable=yes,toolbar=no,scrollbars=yes\"/>
</text>
</item>
<item name=\"txtLinkURL\">
<label><![CDATA[<font class=\'adidascom_textfield\'>Link URL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>Enter Link URL</description>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"118\"><default></default></text>
</item>
</replicant>
</item>
</container>";
}
my $strCatalogueFile = "Y:/default/main/$strRootBranch/WORKAREA/global/config/cmn_product_catalogue.txt ";
open (fhCatalogueFile,"$strCatalogueFile");
$strLineOfCatalogue = <fhCatalogueFile>;
my
@acCatalogueData
;
while ($strLineOfCatalogue ne "" )
{
@acCatalogueData
= split(/;/, $strLineOfCatalogue);
$strLineOfCatalogue = <fhCatalogueFile>;
}
my $iIsCatalogue=0;
my $strCatalogue;
foreach $strCatalogue(
@acCatalogueData
)
{
if ($strCatalogue eq "$strCountry")
{
$iIsCatalogue=1;
}
}
if ($iIsCatalogue == 1)
{
$strDCT=$strDCT."
<container name=\"cntSearch\">
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>Search</td></tr></table>]]></label>
<item name=\"txtHeading\">
<description>Enter Search Heading</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Heading\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"><default></default></text>
</item>
<item name=\"tarIntroText\">
<description>Enter introduction text</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Intro Text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<textarea required=\"t\" validation-regex=\"[^\\s]\" cols=\"88\" rows=\"2\"/>
</item>
<item name=\"txtTextEntryField\">
<description>Enter Text to be searched</description>
<label><![CDATA[<font class=\'adidascom_textfield\'>Text Entry Field\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\" maxlength=\"30\"><default></default></text>
</item>
<item name=\"txtButton\" >
<label><![CDATA[<font class=\'adidascom_textfield\'>Button text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ </font>]]></label>
<description>
Enter the text for dropdown introduction.
</description>
<text required=\"t\" validation-regex=\"[^\\s]\" size = \"30\"/>
</item>
</container>
";
}
$strDCT=$strDCT."
<item name=\"txtIsCatalogue\">
<text size = \"30\"><default>$iIsCatalogue</default></text>
</item>
### This is for DCR and ASP page information
<item name=\"hdnAttachedFiles\">
<label>Filed to capture name of all the included images in this DCR</label>
<hidden>
</hidden>
</item>
<item name=\"hdnPageGenerated\">
<label>Field to capture name of page to be generated.</label>
<hidden>
</hidden>
</item>
<item name=\"hdnPageTpl\">
<label>Field to capture name of Tpl</label>
<hidden>
</hidden>
</item>
</substitution>";
print $strDCT;
Thanks for taking pain for me
Adam Stoller
I could spend a lot of time critiquing your code - (and I may do that anyway ;-)) - but what I don't see here is (a) the data which *might* have '&'s in it, and (b) where you want to transform those '&'s to something else.
As for some early critiques ...
opendir( fhMyDir,"Y:/$strIwBranch/WORKAREA/adidas/sitemap/" );
@acAllFilesInDir
= readdir(fhMyDir);
foreach $files(
@acAllFilesInDir
)
{
$strFiles=$files;
if(!($strFiles =~ /\bzz_tst/))
{
@acFilesInDir[$iArrayLength]=$strFiles
;
$iArrayLength++;
if($files ne "." && $files ne ".." )
{
$iNoOfFilesInDir++;
}
}
}
later you have code like this:for( $iContainerCount = 1; $iContainerCount <= $iNoOfFilesInDir; $iContainerCount++ )
{
$strNameOfFile = "Y:/$strIwBranch/WORKAREA/adidas/sitemap/".$acFilesInDir[$iContainerCount+1];
open (fhLineOfFile,"$strNameOfFile");
$strLineOfFile = <fhLineOfFile>;
$strDCT=$strDCT."<container name=\"cntGroupHeading $iContainerCount\">
<label><![CDATA[<table><tr><td width=950 class=\'adidascom_titlehead\' align=\'left\'>$acFilesInDir[$iContainerCount+1] Page</td></tr></table>]]></label>\n";
...
@}You're starting $iContainerCount with a value of 1, but everytime you access it you're accessing $iContainerCount+1 - which means you're skipping the first two (0, 1) elements of
@acFilesInDir
. Was this intentional? if so - why?
Provide some of the answers to the above and we can go into more depth on your code ...
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com