Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

File Opening

by vinoth.ree (Parson)
on Feb 06, 2010 at 06:37 UTC ( #821713=perlquestion: print w/ replies, xml ) Need Help??
vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

Is opening a file like this open(FH,">"."$path") or die $!;fail some times?

Comment on File Opening
Download Code
Re: File Opening
by biohisham (Priest) on Feb 06, 2010 at 06:58 UTC
    Have you tried it and what did you observe???

    If you are trying the three-argument open each argument would be comma separated.

    In the above line you provided, I suspect that the dot operator is prefixing $path with ">" via concatenation. However, ">" is still interpreted as the mode for output and it opened the file and wrote to it successfully when I tried it...



    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

      I used this code, but some time is says that file can not be opened

        Typical lie
        $ perl -le " for(1..1024){ print $!=$_ } " |grep -i open Too many open files in system Too many open files
        What reason did it give?
      The OP is a troll and you fell for it.
Re: File Opening
by toolic (Chancellor) on Feb 06, 2010 at 14:10 UTC
    open will fail if you do not have permission to write to the specified directory or the file already exists and you do not have pemission to overwrite it. There may be other reasons for it to fail (such as a non-existent directory), which is the reason you used die and $! to tell you why it is failing.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://821713]
Approved by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-09-15 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (147 votes), past polls