in reply to CGI, STDIN and chomp problem: bug?
Well, chomp removes the input record separator (see $/ in perlvar). My guess is that your input record separator is "\n", but your input from <STDIN> has a "\r" in it. So, after $var = <STDIN>, $var ends in either "\r\n" or just "\r". You can take them off like this:
$var =~ s{ \r \n ? \z }{}xms;
As an aside, I think using CGI is somewhat misplaced here. If you're on your way to making a CGI script, your input will almost certainly be entirely handled by the CGI module, and you won't need to worry about how your lines are terminated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CGI, STDIN and chomp problem: bug?
by Not_a_Number (Prior) on Jul 14, 2007 at 15:21 UTC | |
by tye (Sage) on Jul 14, 2007 at 16:25 UTC | |
by Not_a_Number (Prior) on Jul 14, 2007 at 17:23 UTC | |
by daxim (Curate) on Jul 14, 2007 at 19:54 UTC | |
by moritz (Cardinal) on Jul 15, 2007 at 13:56 UTC | |
by Not_a_Number (Prior) on Jul 15, 2007 at 15:21 UTC |