My Perl and programmer newbie-ness keep me foul-fettered in the dungeons of code damnation! There is no release for my wretched soul! Alas! Perhaps the merciful monks can release me?
I can't figure out newlines between Windows and Unix platforms! Ahhhrgg! What a mess!
Here's the deal. Our web server is running Apache on a Unix system and my local machine is Windows XP Pro. I have a datafile of email addresses that I'm reading from on our web server. This list gets dynamically created from another script, pulling emails from our MYSQL database and putting them in the text file, one email per line.
I can create the list fine and I can read from it just fine in my current script. The only problem I run into is when I try to modify the list manually (maybe removing a few lines of emails) and then reuploading it to the server. That is when I become fettered. And there's a lot of wailing and gnashing of teeth because the darn chomp() function doesn't seem to work on my Windows modified .txt file. Then the rest of my script doesn't work.
I've created a crude workaround using the chop() function instead that has given my fevered brow at least some relief.
$lastchar = substr($email,-1); print p,$lastchar; if ($lastchar =~ /[a-zA-Z]/){ } else { print p, "Testing...Last char is not alphabetic"; chop($email); print p,"Testing...found newline, so we're chopping it!"; print p,"Testing...$email after chop " . length($email); }
But isn't there an easier way to set chomp to work with either Windows or Unix newlines? I don't know. I have searched the Good Book (Programming Perl) but could not find the answers.
In reply to Chomp doesn't seem to work by JaredHess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |