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

Write a simple regular expression to match an IP address, e-mail address, city-state-zipcode combination.

15 Answers  


Explain USE and REQUIREMENT statements?

1 Answers  


Explain lexical variables.

1 Answers  


What package you use to create a windows services?

1 Answers  


what are the steps involved in reading a cgi script on the server?

1 Answers  


What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?

1 Answers  


Why we use CGI?

1 Answers   Wipro,


“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?

1 Answers  


Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

1 Answers  


What are the two ways to get private values inside a subroutine?

1 Answers  


how to connect cisco switch uisng perl script

1 Answers   ABC,


We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?

1 Answers   AppLabs,


Categories