<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div>The empty string does work<span style="font-weight: bold;">.</span></div><div><br></div><div style="font-family: Courier New,courier,monaco,monospace,sans-serif;">...<br></div><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               If FILEHANDLE is an undefined lexical ("my")</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               variable the variable is assigned a reference to a</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;">               new anonymous filehandle, otherwise if FILEHANDLE</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               is an expression, its value is used as the name of</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               the real filehandle wanted.  (This is considered a</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;">               symbolic reference, so "use strict 'refs'" should</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               not be in effect.)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">...</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               Open returns nonzero upon success, the undefined</span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">               value otherwise.</span><br><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"></span></span><div><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">...</span></span></div><div><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br></span></span></div><div><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">/tmp> perl -MData::Dumper -lwe '<br>my $fh="";<br>print Dumper $fh;<br>open $fh, "<", "test.txt";<br>print Dumper $fh;<br>print while <$fh>;<br>print Dumper $fh;<br>'<br><span style="background-color: rgb(255, 255, 0);">$VAR1 = '';</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color:
 rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">$VAR1 = '';</span><br style="background-color: rgb(255, 255, 0);"><br>test file<br><br><span style="background-color: rgb(255, 255, 0);">$VAR1 = '';</span><br style="background-color: rgb(255, 255, 0);"></span></span><br></div><div><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">/tmp> perl -MData::Dumper -lwe '<br>my $fh;<br>print Dumper $fh;<br>open $fh, "<", "test.txt";<br>print Dumper $fh;<br>print while <$fh>;<br>print Dumper $fh;<br>'<br><span style="background-color: rgb(255, 255, 0);">$VAR1 = undef;</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">$VAR1 = \*{'::$fh'};</span><br><br>test file<br><br><span style="background-color: rgb(255, 255, 0);">$VAR1 = \*{'::$fh'};</span><br></span></span><span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"></span></span><span><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">/tmp> </span></span>perl -MData::Dumper -lwe '<br>my $fh="F";<br>print Dumper $fh;<br>open $fh, "<", "test.txt";<br>print Dumper $fh;<br>print while <F>;<br>print Dumper $fh;<br>'<br>Name "main::F" used only once: possible typo at -e line 6.<br><span style="background-color: rgb(255, 255, 0);">$VAR1 = 'F';</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">$VAR1 = 'F';</span><br><br>test file<br><br><span style="background-color: rgb(255, 255, 0);">$VAR1 = 'F';</span><br></div><div><br></div><div><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">perl -MData::Dumper -lwe '</span><br style="font-family:
 Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">my $fh="";</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">print Dumper $fh;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: rgb(255, 255, 0);">open $fh, "<", "test.txt"</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: rgb(255, 255, 0);"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: rgb(255, 255, 0);"> or warn Dumper $fh;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">print while
 <$fh>;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">print Dumper $fh;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">$VAR1 = '';</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">test file</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;">$VAR1 = '';</span><br><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> Randal L. Schwartz <merlyn@stonehenge.com><br><b><span style="font-weight: bold;">To:</span></b> Steven Lembark <lembark@wrkhors.com><br><b><span style="font-weight: bold;">Cc:</span></b> chicago-talk@pm.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, July 5, 2011 5:42 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Chicago-talk] OPEN() conditional<br></font><br>
>>>>> "Steven" == Steven Lembark <<a ymailto="mailto:lembark@wrkhors.com" href="mailto:lembark@wrkhors.com">lembark@wrkhors.com</a>> writes:<br><br>Steven> my $fh  = '';<br><br>Did you want autovivification there?  If so, leave $fh as undef, not<br>empty string.<br><br>Steven> open $fh, '<', $path1<br>Steven> or <br>Steven> open $fh, '<', $path2<br>Steven> or <br>Steven> die "$path1, $path2";<br><br>If it accidentally works with empty string, I'd be surprised.<br><br>-- <br>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095<br><<a ymailto="mailto:merlyn@stonehenge.com" href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>> <URL:<a href="http://www.stonehenge.com/merlyn/" target="_blank">http://www.stonehenge.com/merlyn/</a>><br>Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.<br>See http://methodsandmessages.posterous.com/ for Smalltalk
 discussion<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>http://mail.pm.org/mailman/listinfo/chicago-talk<br><br><br></div></div></div></body></html>