Hey Chas,
Saturday, June 16, 2001, 1:47:30 AM, you wrote:
CO> On 15 Jun 2001 19:31:39 -0400, Tim Musson wrote:
>> Hey Chas,
>>
>> Thanks, I run Win2k so had to make some changes (the unix \r\n is just
>> \n on the M$ OS's). I also had a question.
>>
>> {
>> You wrapped some of your code in curlies like this paragraph, and I
>> don't understand why... Seems to work fine without.
>> }
CO> <snip />
CO> Drat, portability issues are a pain. In the c world \n is linefeed and
CO> only linefeed, but in Perl \n is "whatever the line seperator is on this
CO> OS". I guess I should have said "*END*\015\012" in order to insure that
CO> I was looking for CRLF instead of line seperator.
CO> Wraping the code in braces was intentional. It is really not necessary
CO> for this script since it was so simple, but I try to keep good habits
CO> even when I am coding fast (in fact I find it even more important since
CO> I make more mistakes when I am going fast).
CO> Those braces were "bare blocks". Variables declared (my'ed or local'ed)
CO> in blocks (ie sub, for, foreach, while, if, unless, etc) have a lifetime
CO> (AKA scope) of the block. I used them here as sanity checks to make
CO> sure the value of $/ (the record seperator) stayed "\n" for the rest of
CO> the program. If you remove the blocks you might as will remove the
CO> local() as well. Without the {} changing the value of $/ changes it for
CO> the _entire_ program (even with local). This is double plus ungood as
CO> it may screw up code in modules that read from files (or use $/ for
CO> their own nefarious purposes).
Thanks for the response. I had already decided to put them back, and
start using them on a regular basis.
I take it most people come from other languages into Perl (like C).
My other languages were DOS .bat, the ksh shell scripts (tiny bit of
sed and awk thanks to the O'Reilly book). Then I stumbled onto Perl,
and haven't looked back. The only other I wish I knew a little about
is Java, but I still think I will do most things I need in Perl. My
next direction is OOP, but I have found it to be a little beyond my
grasp each time I try. Maybe with this list's help I can get it.
--
[EMAIL PROTECTED]
Using The Bat! eMail v1.53
Windows NT 5.0.2195 (Service Pack 1)
How come wrong numbers are never busy?
NetZero Platinum
No Banner Ads and Unlimited Access
Sign Up Today - Only $9.95 per month!
http://www.netzero.net