binmode command sets up a file for access in binary mode with no mapping of carriage returns. : binmode « File « Perl






binmode command sets up a file for access in binary mode with no mapping of carriage returns.

    


#!/usr/bin/perl -w

# Usage:
#   copy1.pl infile outfile

$input = $ARGV[0];

$output = ">" . $ARGV[1];

open(INPUT, $input) or die "Can't open $input due to $!.";

open(OUTPUT, $output) or die "Can't open $output due to $!.";

# Use shorthand for reading file.
while ( <INPUT> ) {
    print OUTPUT $_;
} 

# Close the files when done.
close (INPUT);
close (OUTPUT);

   
    
    
    
  








Related examples in the same category

1.Change file handle to binary mode
2.Copy file by reading one file and save to another file
3.Win32 Binary Files
4.Unbuffered perl io