From: Peng Yu on
I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
and R in NR stand for.

I think R might stand for numbeR? Does N stand for iNput or liNe?
From: Uri Guttman on
>>>>> "PY" == Peng Yu <pengyu.ut(a)gmail.com> writes:

PY> I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
PY> and R in NR stand for.

PY> I think R might stand for numbeR? Does N stand for iNput or liNe?

Number of Records. it was inherited from awk which has the same variable
NR (from the awk man page):

NR The total number of input records seen so far.

and that also works as the line number so they are the same thing with
different names for historical reasons.

it helps when learning perl to know its major influences which are c,
shell and awk. c is still used as is shell. awk is pretty much a side
player if at all today but when i first learned perl, awk was in heavy
use. in any case many awkish things are in perl such as some names, the
range operator (scalar mode), hashes, the -p option loop, etc.

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Ben Morrow on

Quoth Peng Yu <pengyu.ut(a)gmail.com>:
> I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
> and R in NR stand for.
>
> I think R might stand for numbeR? Does N stand for iNput or liNe?

I presume you are using the English module? I would recommend against
it. Quite apart from the minor performance penalty (which can be avoided
with newer versions of English) the puncuation names are much more
familiar to most Perl programmers.

Ben

From: sachin on
On May 23, 1:36 am, Ben Morrow <b...(a)morrow.me.uk> wrote:
> Quoth Peng Yu <pengyu...(a)gmail.com>:
>
> > I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
> > and R in NR stand for.
>
> > I think R might stand for numbeR? Does N stand for iNput or liNe?
>
> I presume you are using the English module? I would recommend against
> it. Quite apart from the minor performance penalty (which can be avoided
> with newer versions of English) the puncuation names are much more
> familiar to most Perl programmers.
>
> Ben

I believe if the record separator is '\n', and which is by default,
then NR would be same as number of lines. However, if we set the
record separator or delimiter as some other character, then value of
NR might be different.

Please correct me if I am wrong.

Regards,
Sachin
From: Uri Guttman on
>>>>> "s" == sachin <reachsachin(a)gmail.com> writes:

s> On May 23, 1:36�am, Ben Morrow <b...(a)morrow.me.uk> wrote:
>> Quoth Peng Yu <pengyu...(a)gmail.com>:
>>
>> > I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
>> > and R in NR stand for.
>>
>> > I think R might stand for numbeR? Does N stand for iNput or liNe?
>>
>> I presume you are using the English module? I would recommend against
>> it. Quite apart from the minor performance penalty (which can be avoided
>> with newer versions of English) the puncuation names are much more
>> familiar to most Perl programmers.
>>
>> Ben

s> I believe if the record separator is '\n', and which is by default,
s> then NR would be same as number of lines. However, if we set the
s> record separator or delimiter as some other character, then value of
s> NR might be different.

s> Please correct me if I am wrong.

the name is Number of Records. a line is only a record if \n is the
value of $/. so $NR (or more commonly $.) is always correct from that
point of view. if you are reading lines, it is also the line number. so
your point is not really on target.

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------