Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Big problem with @array and Chomp ... I think :o
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Kevin Shay, post: 4746987"] The problem may lie in the first line of code above: @recipients = CGI::param('csvdata'); It sounds like you have a single HTML form field called csvdata, into which the user enters multiple lines of text. If that's the case, the CGI module will not automatically turn this into a list. It's a single value. So the entire set of data is being placed into the first element of @recipients. When you print that one-element array to a file, it simply prints that one element; the element happens to have multiple lines, so the resulting file will have multiple lines. Then, when you re-open the file and do this: @recipients = <ADDRESSES>; Perl reads the lines of the file into the array, one line per element, which is what you wanted in the first place. So you could probably just do this to avoid the whole temp file workaround: @recipients = split(/\n/, CGI::param('csvdata')); As for the actual chomp problem, it may have something to do with the way different operating systems encode newlines differently (\n on Unix, \r\n on DOS/Windows, \r on Mac). Depending on which platform the user's browser is running on, you may not be getting just \n characters separating the lines. So you might want to normalize everything to \n newlines: my $csvdata = CGI::param('csvdata'); $csvdata =~ s/\r\n?/\n/g; @recipients = split(/\n/, $csvdata); Kevin [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Big problem with @array and Chomp ... I think :o
Top