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

What is the difference between chop & chomp functions in perl?

10 Answers   Cap Gemini, DELL, Electronic Data, TCS,


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

0 Answers  


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

0 Answers  


Explain what is perl language?

0 Answers  


What is hash?

0 Answers  






write a script to display mirror image of a entered value and also check whether Palindrome

3 Answers   HCL, Persistent,


how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.

0 Answers  


You want to open and read data files with perl. How would you do that?

0 Answers  


What is the difference between exec and system?

0 Answers  


write a script to generate n prime no.s?

2 Answers   Persistent,


Comment on data types and variables in perl.

0 Answers  


How to replace perl array elements?

0 Answers  


Categories