How do you open a file for writing?

Answers were Sorted based on User's Feedback



How do you open a file for writing? ..

Answer / zech

open FILEHANDLE, ">$FILENAME"

Is This Answer Correct ?    5 Yes 1 No

How do you open a file for writing? ..

Answer / raj

Files are opened using the open and sysopen function.
Either function may be passed up to 4 arguments, the first
is always the file handle thenfile name also known as a URL
or filepath, flags, and finally any permissions to be
granted to this file.

$FH = "filehandle";
$FilePath = "myhtml.html";

open(FH, $FilePath, permissions);
or
sysopen(FH, $FileName, permission);

Is This Answer Correct ?    2 Yes 0 No

How do you open a file for writing? ..

Answer / raghav

To open a file:

open (FILE, "<raghav.txt") || die ("File Cannot be opened");

Where FILE is the file handle for this file.
Here the file is opened in read mode.
Put > for write mode
put >> for append mode.

Is This Answer Correct ?    1 Yes 0 No

How do you open a file for writing? ..

Answer / ankur

open FP,">","myfile.txt";
print FP "Hello World!!";
close FP;

# > for write
# < for read
# >> for read and write

Is This Answer Correct ?    1 Yes 1 No

How do you open a file for writing? ..

Answer / ankur

open FP,">","myfile.txt"
print FP "Hello World!!";
close FP;

Is This Answer Correct ?    0 Yes 2 No

How do you open a file for writing? ..

Answer / shri

Open(FH,">>File.log");
print FH "Hello";
Close FH;

Is This Answer Correct ?    3 Yes 8 No

Post New Answer

More CGI Perl Interview Questions

Why should I use the -w argument with my Perl programs?

0 Answers  


In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?

0 Answers  


What is 'commit' command in perl?

0 Answers  


What are prefix dereferencer? List them.

0 Answers  


What are the purpose of close(), getc() and read() functions?

0 Answers  






What does the command "use strict" do and why should you use it?

2 Answers   Symphony, TCS,


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

0 Answers  


Explain use of ‘my’ keyword in perl?

0 Answers  


How can you create an object of a class in a package?

4 Answers   IBM,


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

0 Answers  


Define dynamic scoping.

0 Answers  


Differentiate between c++ and perl.

0 Answers  


Categories