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

Re: [MacPerl] Changing a file (pseudo) in-place?



At 17:40 2/5/97, Michael Schuerig wrote:
>This is probably obvious, alas, I don't know how to do it.
>I want to change a file. Actually I want to process it's contents, write
>the result to a temp file, exchange the contents of original and temp file,
>and then delete the temp file.
>
>Michael

#       This script fixes problem caused by UNIX text files impported to the
#       Mac in binary mode, so lines are terminated with LF instead of CR.
#       Drop your files on the following droplet:
#!/usr/local/bin/perl5

$/ = "\012";
$^I = ".orig";

@temp = @ARGV;

while (<>) {
    s/\012/\015/g;
    print;
}

foreach (@temp) {
    unlink $_.".orig";
}