Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/File-input-output/Perl/file-input-output.pl
Normal file
18
Task/File-input-output/Perl/file-input-output.pl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
open my $fh_in, '<', 'input.txt' or die "could not open <input.txt> for reading: $!";
|
||||
open my $fh_out, '>', 'output.txt' or die "could not open <output.txt> for writing: $!";
|
||||
# '>' overwrites file, '>>' appends to file, just like in the shell
|
||||
|
||||
binmode $fh_out; # marks filehandle for binary content on systems where that matters
|
||||
|
||||
print $fh_out $_ while <$fh_in>;
|
||||
# prints current line to file associated with $fh_out filehandle
|
||||
|
||||
# the same, less concise
|
||||
#while (<$fh_in>) {
|
||||
# print $fh_out $_;
|
||||
#};
|
||||
|
||||
close $fh_in;
|
||||
close $fh_out;
|
||||
Loading…
Add table
Add a link
Reference in a new issue