{"id":417,"date":"2009-07-16T23:44:38","date_gmt":"2009-07-16T14:44:38","guid":{"rendered":"https:\/\/fugutabetai.com\/blog\/2009\/07\/16\/perl-on-mac-osx-does-not-like\/"},"modified":"2009-07-16T23:44:38","modified_gmt":"2009-07-16T14:44:38","slug":"perl-on-mac-osx-does-not-like","status":"publish","type":"post","link":"https:\/\/fugutabetai.com\/blog\/2009\/07\/16\/perl-on-mac-osx-does-not-like\/","title":{"rendered":"Perl on Mac OSX does not like ~"},"content":{"rendered":"<p>This caused me to lose about thirty minutes of my precious &#8220;not working, not sleeping&#8221; time (currently at about two hours a day.)  <\/p>\n<p>I was trying to run some file test operations on some files in OSX using Perl (one of the newer ones, 5.10 maybe) that have spaces in their names.  In general, I absolute hate how processing files with spaces is so difficult.  One thing I like to do is change the IFS (internal file separator) in bash while doing things with files.  <a href=\"http:\/\/www.cyberciti.biz\/tips\/handling-filenames-with-spaces-in-bash.html\">This blog post<\/a> shows a really nice example of doing that.<\/p>\n<p>Anyway, I was doing something basically like:<\/p>\n<p>if (-e $file &#038;&#038; -f $file) { &#8230; }<\/p>\n<p>for $file where $file was something like &#8220;~\/tmpLibrary\/covers\/Sanderson, Brandon &#8211; Mistborn.jpg&#8221;.  It was failing all the time.  I was also getting mystifying &#8220;failed trying to stat file with newline in it&#8221; error messages when I knew the file name had no newlines.  I still don&#8217;t know what that was about.  Unfortunately, for files that I knew existed and were regular, the above test was failing.<\/p>\n<p>Why?<\/p>\n<p>After much experimentation, lots of googling (there was nothing on this) I figured it out.  And remembered that I knew this was a problem at some point, and must have forgotten.  Perl barf on &#8220;~\/tmpLibrary\/bar.jpg&#8221;.  It will work fine with absolute file paths: &#8220;\/Users\/devans\/tmpLibrary\/bar.jpg&#8221;.  Oh.  That is strange, but I guess I can understand that.  There isn&#8217;t any real reason that Perl should expand the path with the user home location.  I wouldn&#8217;t be surprised if it, and would be (was!) surprised when it didn&#8217;t, but whatever.<\/p>\n<p>So, remember that kids.  Don&#8217;t count on home directory expansion.  Not that I could find anything about that (or spaces in filenames, which work just fine) for perl file operator tests, but there you go.<\/p>\n<p>And I spend my free time doing stuff like this for fun.  I am a sad, sad man.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This caused me to lose about thirty minutes of my precious &#8220;not working, not sleeping&#8221; time (currently at about two hours a day.) I was trying to run some file test operations on some files in OSX using Perl (one of the newer ones, 5.10 maybe) that have spaces in their names. In general, I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts\/417"}],"collection":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/comments?post=417"}],"version-history":[{"count":0,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts\/417\/revisions"}],"wp:attachment":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/media?parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/categories?post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/tags?post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}