What are the various file operations in perl. Explain with example.



What are the various file operations in perl. Explain with example...

Answer / Preeti Arya

Perl provides various functions to perform file operations, such as opening, reading, writing, appending, and closing files. Opening a file is done using the open() function.nnExample: `open(my $fh, '>', 'example.txt') or die "$!"; print $fh 'Hello World'; close($fh);` This opens the file 'example.txt' in write mode, writes 'Hello World', and then closes it.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

1 Answers  


What does perl do in linux?

1 Answers  


If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

1 Answers  


What are the different ways to run cgi?

1 Answers  


How to determine strings length in perl?

1 Answers  


What are perl variables?

1 Answers  


Explain chomp, chop, cpan, tk.

1 Answers  


What are the logical operators used for small scale operations?

1 Answers  


What are scalar data and scalar variables?

1 Answers  


Explain join function in perl?

1 Answers  


Differentiate between arrays and list in perl.

1 Answers  


How can you replace the characters from a string and save the number of replacements?

1 Answers  


Categories