<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>yes ?: works</span></div><br>> ls *.log<br><div><span>sqlnet.log<br>> perl -le '<br>open(F, (-f "asqlnet.log") ? "<asqlnet.log": "<sqlnet.log")<br> or die "oops $!"'<br></span><span>> </span><span>perl -le '<br>open(F, (-f "asqlnet.log") ? "<asqlnet.log": "<bsqlnet.log")<br> or die "oops $!"'<br>oops No such file or directory at -e line 2.<br><br></span></div><div><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> tiger peng <tigerpeng2001@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> Chicago.pm chatter <chicago-talk@pm.org><br><b><span style="font-weight:
 bold;">Sent:</span></b> Thursday, June 30, 2011 2:05 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Chicago-talk] OPEN() conditional<br></font><br>
<div id="yiv1296204104"><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:10pt;"><div><span>if (-f '/blah/blah') {open F, "</blah/blab"} else { </span><span>open F, "</blab"}. <br></span></div><div><br><span></span></div><div><span>maybe ?: will work too.<br></span></div><div><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> Richard Reina <richard@rushlogistics.com><br><b><span style="font-weight:bold;">To:</span></b> chicago-talk@pm.org<br><b><span style="font-weight:bold;">Sent:</span></b> Thursday, June 30, 2011 1:46 PM<br><b><span style="font-weight:bold;">Subject:</span></b> [Chicago-talk] OPEN() conditional<br></font><br>
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?<br><br>Thanks,<br><br>Richard<br>-- <br>Richard Reina<br>Rush Logistics, Inc.<br>Watch our 3 minute movie: <br>http://www.rushlogistics.com/movie<br><br>_______________________________________________<br>Chicago-talk mailing list<br><a rel="nofollow" ymailto="mailto:Chicago-talk@pm.org" target="_blank"
 href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>http://mail.pm.org/mailman/listinfo/chicago-talk<br><br><br></div></div></div></div><br>_______________________________________________<br>Chicago-talk mailing list<br><a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br><br></div></div></div></body></html>