----- Original Message ----- From: "Connie Chan" <[EMAIL PROTECTED]> To: "Paul Johnson" <[EMAIL PROTECTED]> Cc: "Mark Thumper Weisman" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, July 14, 2002 1:03 AM Subject: Re: Newbie about <STDIN>
> > > > I'm curious about your system too. > > > > For me, Win32, ( Me / 98 ) > > > I will use chop, like > > > chop($input); # Kill whatever the last char at a line > > > > On Win32, the line terminator is usually "\015\012", or CRLF. Of > > course, the file you are reading may not have the usual endings for the > > system it is on. Your use or otherwise of binmode() will also affect > > what is read into the string. > > but I am just talking about user input ( ie. Text ). =) > > > > > chop() only removes the last character from the string, so you may be > > left with a CR at the end of the string if you are not careful. > > > > chomp() removes the value of $/ from the end of the string. This is > > generally seen as safer providing, of course, that the value of $/ > > matches what you are wanting to remove. By default that should be the > > case. > > Yes, but I really don't know why, chomp does nothing on my system.... =( > > but I've done a test like this : > > $len = length($orgText); # $orgText has a \n inside. > print length ($orgText) ; # say, I got 5 > chomp ($orgText); > print length ($orgText) ; # still 5, why ??! > chop ($orgText); > print length ($orgText) ; # I got 4 Where exactly is the '\n'? If it is not at the end of the string, chomp will do nothing for you... Shawn > > > I did have an experience that need to upload a script to a unix box... > scripts are totally fail because of the CR, CRLF, at last, I done in this > way $in =~ s/(\n|\r\n)$//; # something like that......... > > Stupid ? Yes, I am still a beginner =) > > Rgds, > Connie > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]