[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: Re[2]: [MacPerl] What am I missing?



Hal Wine writes 30-JUL-1996:

>At 11:58 AM on 7/29/96, dsmall@mitre.org wrote:
>
>>I set $/ to an unused character because otherwise searches would end with
>>each line.  Note that I didn't use an input-output loop, because if my $/
>>character is really unused, my program will read the entire file into $test
>>in one try.
>
>To read a file completely, you should use
>    undef $/;
>That works even if the file has the character you think is unused!

Excellent advice.

>PLEASE, use octal when you're looking for a bit pattern -- it's more
>portable, and clearer:
>
>$LF = "\012";
>$CR = "\015";
>$DOSeol = "$CR$LF";
>$MacEol = "$CR";
>$UNIXeol = "$LF";

Not that this is not excellent advice (I think it is) but I am curious: is 
there some reason not to use hexadecimal or decimal sets? Would there be 
anything wrong with:

$LF = "\x0a";
$CR = "\x0d";

or with:

$LF = pack("c",10);
$CR = pack("c",13);

admittedly the decimal way introduces more typing but I think that the other 
number systems sometimes shy folks off.

>Remember, "\n" does NOT mean ASCII CR!!!!!

OK I remember. I am still curious though.

Peter Prymmer
pvhp@lns62.lns.cornell.edu