[Chicago-talk] OPEN() conditional

tiger peng tigerpeng2001 at yahoo.com
Thu Jun 30 12:05:42 PDT 2011

if (-f '/blah/blah') {open F, "</blah/blab"} else { open F, "</blab"}. 

maybe ?: will work too.

From: Richard Reina <richard at rushlogistics.com>
To: chicago-talk at pm.org
Sent: Thursday, June 30, 2011 1:46 PM
Subject: [Chicago-talk] OPEN() conditional

I am writing a script that among other things edits a file.  The file can be in one of two places (directories) so if the first open does not work I want it to try the open of the file in the alternative directory.  I know how to do open(F, "</blah/blah") || die or open(F, "</lbal") || warn; but I don't want the program to die but to try another directory.  Is there a way to do open() conditionals or do I need to use readdir first to see if the file exists?


Richard Reina
Rush Logistics, Inc.
Watch our 3 minute movie: 

Chicago-talk mailing list
Chicago-talk at pm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110630/993c5354/attachment.html>

More information about the Chicago-talk mailing list