HI Bob,
rather than persist I changed the code so that it would write each option
tag to an array then I print out the array in the heredoc and it works. Be
buggered if I know what the previous problem was though.
Thanks all for your help
#!c:/iw-home/iw-perl/bin/iwperl
my $fileToOpen = shift;
open( FILEHANDLE, $fileToOpen ) or die ("Could not open file
$fileToOpen");
undef $/; # enter slurp mode
my $inFile = <FILEHANDLE>;
close( FILEHANDLE );
my @splitData = split( /\,/, $inFile );
foreach $subject ( @splitData ) {
$subject = xmlEncode($subject);
$optionHTML = qq[<option label="$subject" />];
push( @arrayOptions, $optionHTML );
}
# produce output
print <<EOF;
<?xml version="1.0" encoding='UTF-8'?>
<substitution>
@arrayOptions
</substitution>
EOF
#
sub xmlEncode {
#returns text free of XML baddies - xc = xml clean
my $data = $_[0];
$data =~ s/&/&/g;
$data =~ s/</</g;
$data =~ s/>/>/g;
$data =~ s/\'/'/g;
$data =~ s/\"/"/g;
return $data;
}
__data__
About You,BCS Employee,Sales Recognition Events Framework,BPFJ+,Building
Wealth,Community Program,Compensation,Employment Confirmations,Employee
Development,Employee Services,Executive Development,Expense
Reimbursement,Financial Benefits,Flexibility,Global Pulse Survey,Health
Benefits,Hiring,HR Assist,IDP Tool,Insurance,Manager Services,Management
Development,Mobility,New Hire Information,Other,PaylinkPlus,Payroll
Services,PBC Tool - Urgent,PBC Tool - Normal,Peace of Mind
Benefits,Personnel Records,Promotions,Reporting,Reporting - Data Quality &
Integrity,Site Utilities,Single Cycle Salary Review,Transition
Employees,Transactional,Well Being,When Life Changes,Workforce
Diversity,Workplace Practices,Your Career
__data__
"Bob Showalter" <[EMAIL PROTECTED]>
30/12/2003 02:22 PM
To: Colin Johnstone/Australia/Contr/[EMAIL PROTECTED]
cc: <[EMAIL PROTECTED]>
Subject: Re: Splitting Comma delimited list
Colin Johnstone wrote:
> Bob,
>
> The cms makes those changes. It also inserts comments as shown below
> which
> aren't in my code and wraps it all in the select tags.
A suggestion: Post a message with the input data, the script, and the
actual
output produced *by that script*. Put the input data under a __DATA__ tag.
Leave the cms out of it for now. That way we can run your self-contained
script and see what's going on. Heck, you may even find the problem while
going through this exercise :~)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>