(redirected to list by James)

Begin forwarded message:

From: "Stout, Joel R" <[EMAIL PROTECTED]>
Date: December 29, 2003 3:37:37 PM CST
To: "'James Edward Gray II'" <[EMAIL PROTECTED]>
Subject: RE: Splitting Comma delimited list

Not sure if this helps but there are more xml "baddies" to take care of....


sub xc { #returns text free of XML baddies - xc = xml clean my $data = $_[0]; $data =~ s/&/&amp;/g; $data =~ s/</&lt;/g; $data =~ s/>/&gt;/g; $data =~ s/'/&apos;/g; $data =~ s/"/&quot;/g; return $data; }

-----Original Message-----
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Monday, December 29, 2003 1:27 PM
To: Colin Johnstone
Cc: [EMAIL PROTECTED]
Subject: Re: Splitting Comma delimited list


On Dec 29, 2003, at 3:12 PM, Colin Johnstone wrote:


Hello everyone,

I use the following to split a comma delimited list and get varying
results and I don't understand why.

Running your code on your data, I get the expected results (43).


my count of the elements in the splitdata array returns 43 but the
select
list when displayed in our Content management system only has
approximately 23 items. Some items are compltely ignored. The comma
delimited txt file is below.

Could this be a browser issue? Is the XHTML still correct?


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




#!/usr/bin/perl

# I strongly recommend...


use strict;
use warnings;

my $fileToOpen = shift;

# $string = qq[<option value="$fileToOpen" label="$fileToOpen"/>];

open( FILEHANDLE, $fileToOpen ) or die ("Could not open file
$fileToOpen");

# You'll stay sane longer if you think up file handle names better than FILEHANDLE

while( my $line = <FILEHANDLE> ){
    chomp $line;
    $inFile .= $line;
}

# you can replace the above loop with a single read


undef $/;               # enter slurp mode
my $inFile = <FILEHANDLE>;

close(FILEHANDLE);

my @splitData = split( /\,/, $inFile );

$numElements = scalar(@splitData);
$optionHTML = qq[<option label="$numElements:" />];

foreach $subject(@splitData){

    $subject =~ s/&/&amp;/g;
    $subject =~ s/\"/&quot;/g;
    $optionHTML .= qq[<option label="$subject" />];

}

# produce output
print <<EOF;
<?xml version="1.0" encoding='UTF-8'?>
<substitution>
$optionHTML
</substitution>
EOF
#


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to