Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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