LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-06-2005, 10:49 AM   #1
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Rep: Reputation: 30
perl file handle


whats the difference between

open (OLD, "< file")

open (NEW, "> file2")
 
Old 06-06-2005, 11:16 AM   #2
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 927

Rep: Reputation: 30
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).
 
Old 06-06-2005, 12:06 PM   #3
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
ok so what about this then

open (OLD, "file")
 
Old 06-06-2005, 01:00 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,578

Rep: Reputation: 127Reputation: 127
The file is open as read-only, '<' is not mandatory

try :
perldoc -f open
 
Old 06-06-2005, 01:07 PM   #5
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 927

Rep: Reputation: 30
Or here:

http://www.comp.leeds.ac.uk/Perl/filehandling.html (The first result from google when searching on "Perl file open")
 
Old 06-06-2005, 01:22 PM   #6
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
so this

open (OLD, "file")

is the same thing as this?

open (OLD, "<file")
 
Old 06-06-2005, 01:53 PM   #7
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 927

Rep: Reputation: 30
Yep
 
Old 06-06-2005, 02:34 PM   #8
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
thanks so much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle file names with spaces in them bahadur Programming 14 04-04-2005 12:04 PM
how to handle file names with spaces in them bahadur Programming 3 03-23-2005 05:15 AM
Stale NFS file handle toneys Linux - Networking 1 10-24-2004 02:36 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
how to handle *.img file? nutecinc Linux - Newbie 2 01-28-2003 11:38 AM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration