Not sure if this is the forum for this, but it's one of those little things that makes me love Perl. I had written a script to make a task easier for a group of project managers, and it's on the file server for them to play with. Project Managers being dirty, they could move the script or change the name at whim. It requires a file to be configured for their specific task, and I wanted the default config file (if not specified) to be <scriptname>.cfg, without the .pl extension. What makes me stare at this line of code and get watery-eyed is that I'm using a function in both scalar and list context, in a temporally unsound way. Split is being referenced in a literal context by the @_ default array created by treating split in a list context.
This hurts my brain. =)
substr(($script = $0 = (@_[split(/\\/,$0)-1])),-3) = ".cfg";
$0 = whatever.pl
$script = whatever.cfg

In reply to default config file by Reverend Phil

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.