LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl file handle (https://www.linuxquestions.org/questions/programming-9/perl-file-handle-330874/)

Xris718 06-06-2005 10:49 AM

perl file handle
 
whats the difference between

open (OLD, "< file")

open (NEW, "> file2")

rose_bud4201 06-06-2005 11:16 AM

One reads from the file, and one writes to it.
Specifically, open (OLD, "<file") opens it for reading only. ">" opens with write-ability (if the file you're working with allows you to write to it. If it doesn't, you may get an access error the first time you try to write to the file).

Xris718 06-06-2005 12:06 PM

ok so what about this then

open (OLD, "file")

keefaz 06-06-2005 01:00 PM

The file is open as read-only, '<' is not mandatory

try :
perldoc -f open

rose_bud4201 06-06-2005 01:07 PM

Or here:

http://www.comp.leeds.ac.uk/Perl/filehandling.html (The first result from google when searching on "Perl file open") :)

Xris718 06-06-2005 01:22 PM

so this

open (OLD, "file")

is the same thing as this?

open (OLD, "<file")

rose_bud4201 06-06-2005 01:53 PM

Yep :)

Xris718 06-06-2005 02:34 PM

thanks so much.


All times are GMT -5. The time now is 11:34 AM.