Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • He also says don't put trailing slashes in scalars that are directory names, because then you can "$dir/$file" and it's perfect.

    The one problem with this is that the root directory needs a trailing slash to be correct. The above approach results in $dir = '/', $file = 'foo', "$dir/$file" = '//foo' - it gets a double slash for an important special case. If you always leave the trailing slash, you can use "$dir$file" instead and $dir is correct. Using '/foo/bar/' as a directory name is perhaps a bit ugly but correct. (A doubled slash is also ugly but correct, so you choose whichever ugliness grates less.)
    • Double slash makes it ugly to the OS; not having a slash between filename components makes it ugly to the programmer. I choose making it nice for myself.

      Plus, how often do you need to represent the root directory in a variable? Do you write many temporary files there or anything? Or permanent files? :)

      --
      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers