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/&/&/g; $subject =~ s/\"/"/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>