Hi Martien
Thank you to answer my answer.
Did you at least read the initial question from the initial message

And tried to interpret it and answer it... Seemingly the initial user
is not a pro at Perl and needed to get a solution ready to use.
And? Your point is?
- <STDIN> being empty or false : actually it is finally evaluated to
false
Does playing with words really help the newbie
Accuracy does help. Programmers have to be accurate, because computers
are generally not very forgiving towards inaccurate programs.
- Regarding the 2 chars on a PC coming from Unix - ok you program Perl
since the early nineties ... - but you should know my friend that on
some implementations and depending on the way it has been installed
the "chomp" removes only the \012 (LF) not the \015 (CR) ...
And on those platforms, end-of-line is \012 or \015. Perl's chomp
removes whatever $/ is set to, and that, by default, is set to whatever
the end-of-line on the current platform is.
If you want to remove more than the end-of-line characters, then do so.
However, when you are working with _regular_ text files, you should
never ever worry about end-of-line sequences that might come from other
plartforms. never.
You just finished telling me that you thought the OP was "not a pro at
Perl", yet you decide that it would be a good idea to worry the OP with
this sort of stuff? And apart from that, you didn't just give him
inaccurate information in this resect, but wrong information. i
corrected that. This is Usenet, get used to it.
- STDIN : this is funny

I'm sure you are not answering threads to
show off, since your time is so valuable, but my friend, as you say,
"read the doc"

) All the global special filehandles are given in
uppercase (Perl in a nutshell for instance p.55). You're lucky,
"stdin" works in lowercase. But try with ARGV !!
Te OP used stdin, you started using STDIN. It is by (mis)design that
both work in Perl, but not always. stdin is only synonmous for STDIN in
main::. You switched from one to the other without explaining why you
did that.
The OP should have used STDIN, probably. You didn't explain why.
I do not, and have never advocated the use of stdin above STDIN when
people mean to use the standard input stream. What I remarked was that
the OP used stdin, and you switched to STDIN, which is _not_ the same
thing, in general.
You just finished telling me that you thought the OP was "not a pro at
Perl", yet you decide that it would be a good idea to worry the OP with
the case-insensitivity of STDIN, STDOUT and STDERR, without explaining
that this only is the case in certain circumstances. You should have
sticked with stdin, if you are genuinely worried about the OP not being
"a pro at Perl", or you should have explained why it is better to use
STDIN.
- Regarding $_, yes, you got the point, and, for once, you answered
the user. Good. However I think it is better to forget the C
programming and tend to use $_ instead of other variables (needing
allocation etc...). Moreover it is so convenient to use this default
variable...
That is such nonsense that I don't even know where to start. You are
obviously an idiot. The use of named variables has absolutely nothing
whatsoever to do with C, and everything with good programming practices.
while (<STDIN>)
{
chomp;
s/\015//; # in case your implementation needs it and (for our
friend)if
# you don't want to spend ages to find out where the PC
specific
# config is missing
In my implementation, this garbage would never appear.
Also, you foget that I responded directly to some piece of code you
submitted:
while (<STDIN>) # get line in $_
{
chomp; # removes the unix LF char
s/\015//; # removes the PC CR char
$line = $_; # if you really want the $line var...
.... your process ....
}
I responded specifically to the line "$line = $_;", with the remark that
if you are going to use a named variable, that you should do so at the
start, instead of switching from one to the other in the middle. If you
want to use $_, fine, use it, but if you don't then don't. Don't be
wishy-washy about it, and do both, a little bit.
And you're right, my time is valuable. Too valuable to deal with
trolling idiots like you.
*plonk*
Martien