Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: dos2ux shows cannot open file if it is greater than 2GB size

by ikegami (Pope)
on Mar 13, 2013 at 17:44 UTC ( #1023270=note: print w/ replies, xml ) Need Help??


in reply to Re: dos2ux shows cannot open file if it is greater than 2GB size
in thread dos2ux shows cannot open file if it is greater than 2GB size

It's closer to

open(my $in, '<', $ARGV[0]) or die $!; unlink($ARGV[0]); open(my $out, '>', $ARGV[0]) or die $!; while (<$in>) { s/\r\n/\n/; print($out $_); }


Comment on Re^2: dos2ux shows cannot open file if it is greater than 2GB size
Download Code
Re^3: dos2ux shows cannot open file if it is greater than 2GB size
by shan_emails (Beadle) on Mar 14, 2013 at 14:45 UTC

    Thanks Buddy...It works fine.

    But it takes time to complete.

      You can actually optimize the regular expression using a string termination anchor: s/\r$// That keeps it from having to check the entire string.


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      To speed things up, I'd read more at a time.
      perl -pe'BEGIN { $/ = \(1024*1024); } s/\r//g;' file.in >file.out
      But yeah, it will take time to copy 7GB.

        That will change *ALL* \r in text, not just trailing \r. I do not think that is what dos2ux is supposed to do, though I admit that HP's manual page isn't very clear on that:

        DESCRIPTION dos2ux and ux2dos read each specified file in sequence and write + it to standard output, converting to HP-UX format or to DOS format, respectively. Each file can be either DOS format or HP-UX forma +t for either command. A DOS file name is recognized by the presence of an embedded col +on (:) delimiter; see dosif(4) for DOS file naming conventions. If no input file is given or if the argument - is encountered, d +os2ux and ux2dos read from standard input. Standard input can be comb +ined with other files.

        Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2015-07-05 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls