Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: win2unix

by Courage (Parson)
on Jul 20, 2002 at 08:33 UTC ( #183572=note: print w/ replies, xml ) Need Help??


in reply to win2unix

seems to me like your code snippet will damage a file where ^M are already missing: chomp will remove \n and chop next to it will eat a good character.

Secondly, it will not work on Win32, because you did not used "binmode" on that filehandle.

Additionally I just thought about not important but funny thing: you closed a filehandle because it is a good practice (perldoc says that it's not needed, because perl does this for you).
Let's go further and do even more: let's undefine all defined wariables, return to initial directory, and so on...
:)

Courage, the Cowardly Dog.


Comment on Re: win2unix
Re: Re: win2unix
by ackohno (Scribe) on Jul 20, 2002 at 16:33 UTC
    My experience with files that are mushed up with the ^M's has been that there is one on every line in the file, so naturaly, I didn't realize there could or might be a line without the ^M.

    Whould removeing ^Ms really be useful in windows?

    Hehe, I come from C and C++. Not closeing filehandles is of the devil >:)-|<.

Re: Re: win2unix
by Anonymous Monk on Jul 21, 2002 at 03:16 UTC
    Closing files is probably still a good habbit to get into. Consider:
    That it documents that you won't be messing with a file anymore.
    And if you use flock(), and are into the habbit of NOT closing your files, you could end up with a messy unintentional bottleneck
      I did not complained that it's better not to close filehandles, just joke come into my mind (as I marked it).

      Mostly I tried to spot bugs in that program. Did you noticed that it will eat first innocent first line from a file?

      And, ackohno, to ask your question, yes, I use \r\n=>\n conversion on Win32.

      addition and once again: if you forgot that you already used that program, and use it again, it will damage file by eating it from two sides: almost each time will eat a line from top, and each time eat one character from right side.

      Courage, the Cowardly Dog.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183572]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-08-21 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls