How to copy a file in perl?



How to copy a file in perl?..

Answer / Sahil Chaudhary

In Perl, you can use the 'sysopen' and 'sysread/syswrite' functions to read from one file and write to another. The syntax is: sysopen(my $out_file, $output_filename, O_WRONLY | O_CREAT); while (sysread($in_file, my $line, 4096)) { syswrite($out_file, $line) } close($in_file), close($out_file).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

how to connect cisco switch uisng perl script

1 Answers   ABC,


What are the steps involved in configuring a server using cgi programming?

1 Answers  


How will you access an element of a perl array?

1 Answers  


What are stdin, stdout and stderr?

1 Answers  


Why we use CGI?

1 Answers   Wipro,


Differentiate between c++ and perl.

1 Answers  


Why do you use Perl?

1 Answers  


What is the main function of cookie server?

1 Answers  


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

1 Answers  


What is the difference between for & foreach, exec & system?

9 Answers   Photon, Wipro,


Does Perl have reference type?

1 Answers  


What is “grep” function in perl?

1 Answers  


Categories